course_section_test.rb 709 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
19
20
21
22
                          course_id: courses(:cs211).id,
                          instructor_id: instructors(:luke).id
  end

  test '#with_instructor filters correctly' do
    section = CourseSection.with_instructor.first
    assert section.instructor_name != ""
23
  end
Zac Wood's avatar
Zac Wood committed
24
end