Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
schedules
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Khalid Ali
schedules
Commits
cdadfe65
Commit
cdadfe65
authored
Aug 01, 2018
by
Zac Wood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added search by CRN for course sections
parent
b5bd4381
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
2 deletions
+14
-2
schedules_api/app/controllers/course_sections_controller.rb
schedules_api/app/controllers/course_sections_controller.rb
+5
-1
schedules_api/test/controllers/course_sections_controller_test.rb
...s_api/test/controllers/course_sections_controller_test.rb
+8
-0
schedules_api/test/fixtures/course_sections.yml
schedules_api/test/fixtures/course_sections.yml
+1
-1
No files found.
schedules_api/app/controllers/course_sections_controller.rb
View file @
cdadfe65
...
...
@@ -3,7 +3,11 @@
class
CourseSectionsController
<
ApplicationController
# Render JSON of all Sections belonging to a given Course.
def
index
@sections
=
CourseSection
.
where
(
course_id:
params
[
:course_id
])
@sections
=
CourseSection
.
all
@sections
=
@sections
.
where
(
course_id:
params
[
:course_id
])
if
params
.
key?
(
:course_id
)
@sections
=
@sections
.
where
(
crn:
params
[
:crn
])
if
params
.
key?
(
:crn
)
render
json:
@sections
end
end
schedules_api/test/controllers/course_sections_controller_test.rb
View file @
cdadfe65
...
...
@@ -10,4 +10,12 @@ class CourseSectionsControllerTest < ActionDispatch::IntegrationTest
assert_equal
num_sections
,
sections_returned
.
count
end
test
'should filter by crn'
do
get
course_sections_url
crn:
course_sections
(
:cs112001
).
crn
assert_response
:success
sections_returned
=
JSON
.
parse
@response
.
body
assert_equal
course_sections
(
:cs112001
).
name
,
sections_returned
[
0
][
"name"
]
end
end
schedules_api/test/fixtures/course_sections.yml
View file @
cdadfe65
...
...
@@ -37,7 +37,7 @@ cs112002:
course
:
cs112
cs211001
:
name
:
MyString
name
:
MyString
3
crn
:
MyString3
section_type
:
MyString
title
:
MyString
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment