Commit 43791089 authored by Zac Wood's avatar Zac Wood

Added Semesters endpoint to API

parent a3f53830
Pipeline #3849 failed with stage
in 2 minutes and 45 seconds
class API::SemestersController < ApplicationController
def index
result = Semester.all.map do |s|
{
id: s.id,
season: s.season,
year: s.year
}
end
render json: result
end
end
......@@ -12,6 +12,7 @@ Rails.application.routes.draw do
get 'schedule/view', to: 'schedules#view', as: 'view_schedule'
scope :api, module: 'api' do # Register /api routes
resources :semesters, only: [:index], as: 'api_semesters'
resources :courses, only: [:index, :show], as: 'api_courses'
resources :course_sections, only: [:index], as: 'api_course_sections'
resources :instructors, only: [:index, :show], as: 'api_instructors'
......
......@@ -116,7 +116,7 @@ def main
[parser.parse_semesters.first]
else
# expand to include however many semesters you want
parser.parse_semesters[0..2]
parser.parse_semesters[0..6]
end
......
require 'test_helper'
class API::SemestersControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment