Commit 45df0731 authored by Zac Wood's avatar Zac Wood
Browse files

the tests might actually pass now

parent f444af2e
Pipeline #3299 passed with stage
in 2 minutes and 9 seconds
...@@ -13,3 +13,6 @@ Style/SymbolArray: ...@@ -13,3 +13,6 @@ Style/SymbolArray:
Metrics/BlockLength: Metrics/BlockLength:
Enabled: false Enabled: false
Style/ClassAndModuleChildren:
Enabled: false
...@@ -7,7 +7,7 @@ class API::CoursesController < ApplicationController ...@@ -7,7 +7,7 @@ class API::CoursesController < ApplicationController
api :GET, '/courses', "Get a list of courses." api :GET, '/courses', "Get a list of courses."
param :subject, String, desc: 'Course subject, e.g. "CS" or "ACCT"' param :subject, String, desc: 'Course subject, e.g. "CS" or "ACCT"'
param :course_number, Integer, desc: 'Course number, e.g. "112"' param :course_number, Integer, desc: 'Course number, e.g. "112"'
def index def index
@courses = Course.fetch(params).all @courses = Course.fetch(params).all
render json: @courses render json: @courses
end end
......
...@@ -7,7 +7,7 @@ class ApplicationController < ActionController::Base ...@@ -7,7 +7,7 @@ class ApplicationController < ActionController::Base
@semester = if cookies.key?(:semester_id) @semester = if cookies.key?(:semester_id)
Semester.find_by(id: cookies[:semester_id]) Semester.find_by(id: cookies[:semester_id])
else else
sem = Semester.find_by(season: 'Spring', year: '2019') sem = Semester.first
cookies[:semester_id] = sem.id cookies[:semester_id] = sem.id
sem sem
end end
......
class CoursesController < ApplicationController class CoursesController < ApplicationController
before_action :set_course before_action :set_course
def show def show; end
end
private private
......
...@@ -21,5 +21,4 @@ class SchedulesController < ApplicationController ...@@ -21,5 +21,4 @@ class SchedulesController < ApplicationController
# this works(?) # this works(?)
# recursively build a list of sets containing 1 section from each course chosen # recursively build a list of sets containing 1 section from each course chosen
end end
...@@ -9,7 +9,7 @@ class SessionsController < ApplicationController ...@@ -9,7 +9,7 @@ class SessionsController < ApplicationController
def cart def cart
section_id = params[:section_id] section_id = params[:section_id]
if @cart.include?(section_id) if @cart.include?(section_id)
@cart.reject! { |id| section_id == id } @cart.reject! { |id| section_id == id }
else else
...@@ -20,8 +20,6 @@ class SessionsController < ApplicationController ...@@ -20,8 +20,6 @@ class SessionsController < ApplicationController
cookies[:cart] = @cart.to_json cookies[:cart] = @cart.to_json
render json: @cart.to_json render json: @cart.to_json
end end
private private
......
...@@ -2,7 +2,7 @@ module SearchHelper ...@@ -2,7 +2,7 @@ module SearchHelper
def in_cart?(id) def in_cart?(id)
@cart.include? id.to_s @cart.include? id.to_s
end end
class GenericQueryData class GenericQueryData
attr_reader :semester attr_reader :semester
attr_reader :sort_mode attr_reader :sort_mode
......
...@@ -15,7 +15,7 @@ class Course < ApplicationRecord ...@@ -15,7 +15,7 @@ class Course < ApplicationRecord
def full_name def full_name
"#{subject} #{course_number}" "#{subject} #{course_number}"
end end
def self.from_subject(base_query, subject) def self.from_subject(base_query, subject)
base_query.where("courses.subject = ?", subject.upcase) base_query.where("courses.subject = ?", subject.upcase)
end end
......
...@@ -10,6 +10,6 @@ class Semester < ApplicationRecord ...@@ -10,6 +10,6 @@ class Semester < ApplicationRecord
validates :season, presence: true validates :season, presence: true
def to_s def to_s
return "#{season} #{year}" "#{season} #{year}"
end end
end end
...@@ -14,13 +14,13 @@ Rails.application.config.assets.paths << Rails.root.join('node_modules') ...@@ -14,13 +14,13 @@ Rails.application.config.assets.paths << Rails.root.join('node_modules')
Rails.application.config.assets.precompile += %w( Rails.application.config.assets.precompile += %w(
search.js search.js
search.scss search.scss
schedules.js schedules.js
schedules.scss schedules.scss
cart.js cart.js
cart.scss cart.scss
FileSaver.js FileSaver.js
masonstrap.min.css masonstrap.min.css
masonstrap.min.js masonstrap.min.js
......
...@@ -7,7 +7,7 @@ Rails.application.routes.draw do ...@@ -7,7 +7,7 @@ Rails.application.routes.draw do
resources :courses, only: [:show] resources :courses, only: [:show]
resources :instructors, only: [:index, :show] resources :instructors, only: [:index, :show]
get 'schedule', to: 'schedules#show', as: 'schedule' get 'schedule', to: 'schedules#show', as: 'schedule'
scope :api, module: 'api' do # Register /api routes scope :api, module: 'api' do # Register /api routes
resources :courses, only: [:index, :show], as: 'api_courses' resources :courses, only: [:index, :show], as: 'api_courses'
resources :course_sections, only: [:index], as: 'api_course_sections' resources :course_sections, only: [:index], as: 'api_course_sections'
......
require 'test_helper' require 'test_helper'
class API::CoursesControllerTest < ActionDispatch::IntegrationTest class API::CoursesControllerTest < ActionDispatch::IntegrationTest
semester_id = semesters(:fall2018).id
test '#index should return all courses' do test '#index should return all courses' do
get api_courses_url get api_courses_url
assert_response :success assert_response :success
......
...@@ -2,13 +2,13 @@ require 'test_helper' ...@@ -2,13 +2,13 @@ require 'test_helper'
class API::SchedulesControllerTest < ActionDispatch::IntegrationTest class API::SchedulesControllerTest < ActionDispatch::IntegrationTest
test "should generate schedule" do test "should generate schedule" do
crns = [course_sections(:cs112001).crn, course_sections(:cs112002).crn] ids = [course_sections(:cs112001).id, course_sections(:cs112002).id]
get "/api/schedules?crns=#{crns.join(',')}" get "/api/schedules?section_ids=#{ids.join(',')}"
# DTSTAMP and UID lines uniquely identify events, so we can't test against them. # DTSTAMP and UID lines uniquely identify events, so we can't test against them.
# so remove all the lines starting with them. # so remove all the lines starting with them.
# the \r characters are also annoying so just remove them too # the \r characters are also annoying so just remove them too
gen = @response.body.split("\n").select { |line| !line.include?("DTSTAMP") && !line.include?("UID") }.join("\n").delete("\r") gen = @response.body.split("\n").reject { |line| line.include?("DTSTAMP") || line.include?("UID") }.join("\n").delete("\r")
correct_ical = File.open("test/test.ics").read.delete("\r") correct_ical = File.open("test/test.ics").read.delete("\r")
assert_equal correct_ical, gen assert_equal correct_ical, gen
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