course_section_test.rb 904 Bytes
Newer Older
Zac Wood's avatar
Zac Wood committed
1
2
require 'test_helper'

Zac Wood's avatar
Zac Wood committed
3
class CourseSectionTest < ActiveSupport::TestCase
4
5
  test 'fails with improper data' do
    assert_raise do
Zac Wood's avatar
Zac Wood committed
6
      CourseSection.create! name: nil,
Zac Wood's avatar
Zac Wood committed
7
8
                            crn: nil,
                            title: nil
9
10
11
12
    end
  end

  test 'succeeds with proper data' do
Zac Wood's avatar
Zac Wood committed
13
    CourseSection.create! name: 'Test section',
Zac Wood's avatar
Zac Wood committed
14
15
                          crn: '12345',
                          title: 'Test title',
16
17
18
                          course: courses(:cs211),
                          instructor: instructors(:luke),
                          semester: semesters(:fall2018)
19
20
21
22
23
  end

  test '#with_instructor filters correctly' do
    section = CourseSection.with_instructor.first
    assert section.instructor_name != ""
24
  end
25
26
27

  test '#latest_by_crn sorts correctly' do
    s = CourseSection.latest_by_crn(70192)
28
    assert_equal semesters(:fall2018).id, s.semester.id
29
  end
Zac Wood's avatar
Zac Wood committed
30
end