Commit 9f414f1f authored by Zach Perkins's avatar Zach Perkins
Browse files

Made the course listing endpoint plural

parent d86148c2
class CourseListingController < ApplicationController class CourseListingsController < ApplicationController
resource_description do resource_description do
short 'Working with courses and associated sections' short 'Working with courses and associated sections'
end end
api :GET, '/course_listing', "Get all available courses and their sections" api :GET, '/course_listings', "Get all available courses and their sections"
param :subject, String, desc: 'Course subject, e.g. "CS" or "ACCT"' param :subject, String, desc: 'Course subject, e.g. "CS" or "ACCT"'
param :number, Integer, desc: 'Course number, e.g. "112"' param :number, Integer, desc: 'Course number, e.g. "112"'
def index def index
......
...@@ -5,7 +5,7 @@ class CourseSectionsController < ApplicationController ...@@ -5,7 +5,7 @@ class CourseSectionsController < ApplicationController
short 'Working with course sections, e.g. CS 112 001' short 'Working with course sections, e.g. CS 112 001'
end end
api :GET, '/courses_sections', 'Get a list of course sections' api :GET, '/course_sections', 'Get a list of course sections'
param :course_id, Integer, desc: "Only get the course sections belonging to the course with this ID" param :course_id, Integer, desc: "Only get the course sections belonging to the course with this ID"
param :crn, String, desc: "Get the course section with this CRN" param :crn, String, desc: "Get the course section with this CRN"
param :instructor, String, desc: "Get course sections being taught by this instructor" param :instructor, String, desc: "Get course sections being taught by this instructor"
......
...@@ -6,7 +6,7 @@ Rails.application.routes.draw do ...@@ -6,7 +6,7 @@ Rails.application.routes.draw do
scope :api do # Register /api routes scope :api do # Register /api routes
resources :courses, only: [:index, :show, :listing] resources :courses, only: [:index, :show, :listing]
resources :course_sections, only: [:index] resources :course_sections, only: [:index]
resources :course_listing, only: [:index] resources :course_listings, only: [:index]
resources :schedules, only: [:index] resources :schedules, only: [:index]
end end
......
require 'test_helper'
class CourseListingControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end
require 'test_helper'
class CourseListingsControllerTest < ActionDispatch::IntegrationTest
test 'should grab sections for course' do
get course_listings_url course_id: courses(:cs112).id
assert_response :success
listing_returned = JSON.parse @response.body
assert listing_returned.size.positive?
assert listing_returned[0].include?("sections")
assert_equal(listing_returned[0]["sections"].length(), 2)
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