schedules_controller_test.rb 734 Bytes
Newer Older
1
2
require 'test_helper'

Zac Wood's avatar
Zac Wood committed
3
class API::SchedulesControllerTest < ActionDispatch::IntegrationTest
4
  test "should generate schedule" do
Zac Wood's avatar
Zac Wood committed
5
    ids = [course_sections(:cs112001).id, course_sections(:cs112002).id]
6
    get "/api/schedules?section_ids=#{ids.join(',')}&semester_id=#{semesters(:fall2018).id}"
7
8
9
10

    # 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
Zac Wood's avatar
Zac Wood committed
11
    gen = @response.body.split("\n").reject { |line| line.include?("DTSTAMP") || line.include?("UID") }.join("\n").delete("\r")
Zac Wood's avatar
Zac Wood committed
12
    correct_ical = File.open("test/test.ics").read.delete("\r")
13
    assert_equal correct_ical, gen
14
15
  end
end