Commit 7a2a9aff authored by Zac Wood's avatar Zac Wood

rubo 馃懏

parent 43791089
Pipeline #3850 passed with stage
in 2 minutes and 45 seconds
......@@ -11,10 +11,10 @@ class API::CourseSectionsController < ApplicationController
param :instructor, String, desc: "Get course sections being taught by this instructor"
def index
@sections = CourseSection
.where(semester: @semester)
.joins(:course)
.joins(:instructor)
.select('course_sections.*, instructors.name AS instructor_name')
.where(semester: @semester)
.joins(:course)
.joins(:instructor)
.select('course_sections.*, instructors.name AS instructor_name')
if params.key?(:course_id)
@sections = @sections.where(course_id: params[:course_id])
......
......@@ -7,7 +7,7 @@ class API::SemestersController < ApplicationController
year: s.year
}
end
render json: result
end
end
......@@ -3,8 +3,8 @@ class CourseSection < ApplicationRecord
# Each +CourseSection+ belongs to a +Course+ and an +Instructor+.
belongs_to :course
belongs_to :instructor
# Each course belongs to a +Semester+
# Each course belongs to a +Semester+
belongs_to :semester
# Ensure all necessary fields are present.
......
......@@ -119,7 +119,6 @@ def main
parser.parse_semesters[0..6]
end
puts "\tParsing subjects..."
subjects = parser.parse_subjects(semesters.first[:value])
......@@ -128,7 +127,7 @@ def main
puts "\tLoading courses..."
load_courses(courses)
semesters.each do |semester|
puts "#{semester[:season]} #{semester[:year]}"
db_semester = Semester.find_or_create_by!(season: semester[:season], year: semester[:year])
......
......@@ -4,13 +4,13 @@ class API::CourseSectionsControllerTest < ActionDispatch::IntegrationTest
test 'should get index' do
get api_course_sections_url(course_id: courses(:cs112).id,
semester_id: semesters(:fall2018).id)
assert_response :success
sections_returned = JSON.parse @response.body
num_sections = CourseSection
.where(course_id: courses(:cs112).id)
.where(semester: semesters(:fall2018)).count
.where(course_id: courses(:cs112).id)
.where(semester: semesters(:fall2018)).count
assert_equal num_sections, sections_returned.count
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