Commit e942a5d2 authored by Zach Perkins's avatar Zach Perkins

Fixed crashing with numbers

parent 9f414f1f
......@@ -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
......
......@@ -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]
......
......@@ -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
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