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:
Metrics/BlockLength:
Enabled: false
Style/ClassAndModuleChildren:
Enabled: false
......@@ -7,7 +7,7 @@ class ApplicationController < ActionController::Base
@semester = if cookies.key?(:semester_id)
Semester.find_by(id: cookies[:semester_id])
else
sem = Semester.find_by(season: 'Spring', year: '2019')
sem = Semester.first
cookies[:semester_id] = sem.id
sem
end
......
class CoursesController < ApplicationController
before_action :set_course
def show
end
def show; end
private
......
......@@ -21,5 +21,4 @@ class SchedulesController < ApplicationController
# this works(?)
# recursively build a list of sets containing 1 section from each course chosen
end
......@@ -21,8 +21,6 @@ class SessionsController < ApplicationController
render json: @cart.to_json
end
private
def update_cookie(sym)
......
......@@ -10,6 +10,6 @@ class Semester < ApplicationRecord
validates :season, presence: true
def to_s
return "#{season} #{year}"
"#{season} #{year}"
end
end
require 'test_helper'
class API::CoursesControllerTest < ActionDispatch::IntegrationTest
semester_id = semesters(:fall2018).id
test '#index should return all courses' do
get api_courses_url
assert_response :success
......
......@@ -2,13 +2,13 @@ require 'test_helper'
class API::SchedulesControllerTest < ActionDispatch::IntegrationTest
test "should generate schedule" do
crns = [course_sections(:cs112001).crn, course_sections(:cs112002).crn]
get "/api/schedules?crns=#{crns.join(',')}"
ids = [course_sections(:cs112001).id, course_sections(:cs112002).id]
get "/api/schedules?section_ids=#{ids.join(',')}"
# DTSTAMP and UID lines uniquely identify events, so we can't test against them.
# so remove all the lines starting with them.
# 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")
assert_equal correct_ical, gen
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