Verified Commit 7f99224c authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻
Browse files

feat(semester_process_volunteer): add #missions method with spec

parent 3d4d024a
......@@ -18,4 +18,9 @@ class SemesterProcessVolunteer < ApplicationRecord
has_many :semester_process_mails, dependent: :destroy
has_many :mails, -> { mail }, through: :semester_process_mails
has_many :reminders, -> { reminder }, through: :semester_process_mails
# will only return an array, not a AD-result
def missions
assignments + group_assignments
end
end
require 'test_helper'
class SemesterProcessVolunteerTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test '#mission returns array with all kind of related assignment or group_assignments' do
volunteer = create(:volunteer_with_user)
assignment = create(:assignment, volunteer: volunteer)
group_assignment = create(:group_assignment, volunteer: volunteer)
subject = create(:semester_process_volunteer, volunteer: volunteer,
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
end
Supports Markdown
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