semester_process_volunteer_test.rb 1.21 KB
Newer Older
1
2
3
require 'test_helper'

class SemesterProcessVolunteerTest < ActiveSupport::TestCase
4
5
6
7
8
9
10
  def setup
    @volunteer = create(:volunteer_with_user)
    @assignment = create(:assignment, volunteer: @volunteer)
    @group_assignment = create(:group_assignment, volunteer: @volunteer)
    @subject = create(:semester_process_volunteer, volunteer: @volunteer)
  end

11
  test '#mission returns array with all kind of related assignment or group_assignments' do
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    @subject.update(semester_process_volunteer_missions: [
      build(:semester_process_volunteer_mission, mission: @assignment),
      build(:semester_process_volunteer_mission, mission: @group_assignment)
    ])
    result = @subject.missions
    assert result.include? @assignment
    assert result.include? @group_assignment
  end

  test 'has_many mails and reminders relations work' do
    mail = create(:semester_process_mail, semester_process_volunteer: @subject)
    reminder = create(:semester_process_mail, :as_reminder, semester_process_volunteer: @subject)

    assert @subject.reload.mails.include? mail
    assert_not @subject.reload.mails.include? reminder
27

28
29
    assert_not @subject.reload.reminders.include? mail
    assert @subject.reload.reminders.include? reminder
30
  end
31
end