Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
schedules
Commits
e942a5d2
Commit
e942a5d2
authored
Sep 26, 2018
by
Zach Perkins
Browse files
Fixed crashing with numbers
parent
9f414f1f
Changes
3
Hide whitespace changes
Inline
Side-by-side
schedules/app/models/course.rb
View file @
e942a5d2
...
...
@@ -74,10 +74,10 @@ class Course < ApplicationRecord
query
.
remove!
(
s
)
end
end
query
.
scan
(
/(?<= |^)(\d{3})(?=$| )/
).
each
do
|
a
|
s
=
a
[
0
]
next
unless
filters
.
include?
(
"subject"
)
||
from_course_number
(
from_subject
(
select
(
"*"
),
filters
[
"subject"
]),
s
).
count
.
positive?
next
unless
filters
.
include?
(
"subject"
)
&&
from_course_number
(
from_subject
(
select
(
"*"
),
filters
[
"subject"
]),
s
).
count
.
positive?
filters
[
"course_number"
]
=
s
query
.
remove!
(
s
)
return
filters
...
...
schedules/config/routes.rb
View file @
e942a5d2
...
...
@@ -4,7 +4,7 @@ Rails.application.routes.draw do
get
'search/update'
,
to:
'search#update'
scope
:api
do
# Register /api routes
resources
:courses
,
only:
[
:index
,
:show
,
:listing
]
resources
:courses
,
only:
[
:index
,
:show
]
resources
:course_sections
,
only:
[
:index
]
resources
:course_listings
,
only:
[
:index
]
resources
:schedules
,
only:
[
:index
]
...
...
schedules/test/controllers/course_listings_controller_test.rb
View file @
e942a5d2
...
...
@@ -4,12 +4,12 @@ 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
)
assert_equal
(
listing_returned
[
0
][
"sections"
].
length
,
2
)
end
end
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