Commit 93fa16c8 authored by Tugce Nur Tas's avatar Tugce Nur Tas
Browse files

update tests, since setting an end-date shouldn't create a GroupAssignmentLog anymore

parent 083ccd9c
Pipeline #13952 passed with stage
in 28 minutes and 13 seconds
require 'test_helper'
class GroupAssignmentArchiveTest < ActiveSupport::TestCase
test 'change_period_start_creates_log' do
test 'change_period_start_does_not_create_a_log' do
group_assignment = create :group_assignment, period_start: 100.days.ago, period_end: nil
assert group_assignment.group_assignment_logs.size.zero?
group_assignment.update(period_start: 50.days.ago)
group_assignment.reload
assert_equal group_assignment, group_assignment.group_assignment_logs.first.group_assignment
assert group_assignment.present?
refute group_assignment.group_assignment_logs.any?
end
test 'set_period_end_creates_log' do
test 'set_period_end_does_not_create_a_log' do
group_assignment = create :group_assignment, period_start: 100.days.ago, period_end: nil
assert group_assignment.group_assignment_logs.size.zero?
group_assignment.update(period_end: 2.days.ago)
group_assignment.reload
assert_equal group_assignment, group_assignment.group_assignment_logs.first.group_assignment
assert group_assignment.ended?
refute group_assignment.group_assignment_logs.any?
end
test 'terminating_group_assignment_creates_log_and_deletes_self' do
test 'terminating_group_assignment_creates_log_but_not_deletes_self' do
superadmin = create :user
group_assignment = create :group_assignment, period_start: 100.days.ago, period_end: 3.days.ago,
group_assignment = create :group_assignment, period_start: 100.days.ago,
period_end: 3.days.ago,
period_end_set_by: superadmin, termination_submitted_at: 2.days.ago,
termination_submitted_by: superadmin
assert group_assignment.group_assignment_logs.size.zero?
group_assignment.update(termination_verified_at: Time.zone.now,
termination_verified_by: superadmin)
group_assignment.verify_termination(superadmin)
group_assignment.reload
assert_equal group_assignment, group_assignment.group_assignment_logs.first.group_assignment
assert group_assignment.deleted?
assert group_assignment.group_assignment_logs.first.group_assignment
refute group_assignment.deleted?
end
test 'destroying_group_assignment_creates_log' do
test 'destroying_group_assignment_does_not_create_log_if_not_verified' do
group_assignment = create :group_assignment, period_start: 100.days.ago, period_end: nil
assert group_assignment.group_assignment_logs.size.zero?
group_assignment.destroy
group_assignment.reload
assert_equal group_assignment, group_assignment.group_assignment_logs.first.group_assignment
refute group_assignment.group_assignment_logs.any?
assert group_assignment.deleted?
end
......
......@@ -127,7 +127,7 @@ class GroupAssignmentScopesTest < ActiveSupport::TestCase
refute query.include? started_no_end
refute query.include? started_with_end
assert query.include? submitted
refute query.include? verified
assert query.include? verified
end
test 'termination_not_submitted scope test' do
......@@ -189,7 +189,7 @@ class GroupAssignmentScopesTest < ActiveSupport::TestCase
refute query.include? started_no_end
refute query.include? started_with_end
refute query.include? submitted
refute query.include? verified
assert query.include? verified
query_deleted = GroupAssignment.with_deleted.terminated
refute query_deleted.include? started_no_end
refute query_deleted.include? started_with_end
......
......@@ -42,11 +42,6 @@ class RemoveVolunteerGroupOffersTest < ApplicationSystemTestCase
assert page.has_link? 'Beendigungsformular an Freiwillige/n',
href: polymorphic_path([@ga1, ReminderMailing], action: :new_termination)
end
within '.log-table' do
assert page.has_text? "#{@ga1.volunteer.contact.full_name} "\
"#{@ga1.responsible ? 'Responsible' : 'Member'} #{I18n.l(@ga1.period_start)} "
assert page.has_text? I18n.l(@ga1.period_end)
end
end
test 'changing_volunteer_to_member_works' do
......
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