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
short 'Working with courses and associated sections'
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 :number, Integer, desc: 'Course number, e.g. "112"'
def index
......@@ -5,7 +5,7 @@ class CourseSectionsController < ApplicationController
short 'Working with course sections, e.g. CS 112 001'
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 :crn, String, desc: "Get the course section with this CRN"
param :instructor, String, desc: "Get course sections being taught by this instructor"
......@@ -6,7 +6,7 @@ Rails.application.routes.draw do
scope :api do # Register /api routes
resources :courses, only: [:index, :show, :listing]
resources :course_sections, only: [:index]
resources :course_listing, only: [:index]
resources :course_listings, only: [:index]
resources :schedules, only: [:index]
require 'test_helper'
class CourseListingControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# 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)
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