Commit 4fe93198 authored by Zsolt Benke's avatar Zsolt Benke
Browse files

Don't show terminated assigments

parent 983ce4db
Pipeline #21142 passed with stage
in 33 minutes and 9 seconds
......@@ -28,9 +28,11 @@ class ReminderMailingsController < ApplicationController
end
def new_half_year
@reminder_mailables = Assignment.with_actively_registered_volunteer
@reminder_mailables = Assignment.unterminated
.with_actively_registered_volunteer
.submitted_since(params[:submitted_since]&.to_date)
@reminder_mailables += GroupAssignment.with_actively_registered_volunteer
@reminder_mailables += GroupAssignment.unterminated
.with_actively_registered_volunteer
.submitted_since(params[:submitted_since]&.to_date)
@reminder_mailing = ReminderMailing.new(kind: 'half_year',
reminder_mailing_volunteers: @reminder_mailables)
......
......@@ -34,5 +34,18 @@ FactoryBot.define do
factory :assignment_blank_period, traits: [:blank_period]
factory :assignment_active, traits: [:active]
factory :assignment_inactive, traits: [:inactive]
factory :terminated_assignment do
period_end { 4.days.ago }
termination_submitted_at { 3.days.ago }
termination_verified_at { 2.days.ago }
association :period_end_set_by, factory: :user
after(:build) do |assignment|
assignment.volunteer ||= create(:volunteer)
assignment.termination_submitted_by = assignment.volunteer.user
assignment.termination_verified_by = assignment.period_end_set_by
end
after(:create, &:create_log_of_self)
end
end
end
......@@ -13,6 +13,8 @@ class ReminderMailingsTest < ApplicationSystemTestCase
test 'group_assignment_and_assignment_elegible_for_half_year_reminder_mailing_are_includable' do
group_offer = create :group_offer
terminated_group_assignment = create :terminated_group_assignment
terminated_assignment = create :terminated_assignment
volunteer_assignment = create :volunteer
volunteer_group_offer = create :volunteer
assignment = create :assignment, period_start: 6.months.ago, period_end: nil,
......@@ -24,18 +26,40 @@ class ReminderMailingsTest < ApplicationSystemTestCase
another_group_assignment = GroupAssignment.create(volunteer: volunteer_group_offer, period_end: nil,
group_offer: group_offer, period_start: 6.months.ago)
create :email_template_half_year
terminated_assignment.volunteer.user.update last_sign_in_at: Time.now
terminated_group_assignment.volunteer.user.update last_sign_in_at: Time.now
login_as @superadmin
visit reminder_mailings_path
page.find_all('a', text: 'Halbjahres Erinnerung erstellen').first.click
assert page.has_link? assignment.to_label, href: assignment_path(assignment)
assert page.has_link? assignment.volunteer.contact.full_name, href: volunteer_path(assignment.volunteer)
assert page.has_link? group_assignment.to_label, href: group_offer_path(group_assignment.group_offer)
assert page.has_link? group_assignment.volunteer.contact.full_name, href: volunteer_path(group_assignment.volunteer)
refute page.has_link? another_assignment.to_label, href: assignment_path(another_assignment)
refute page.has_link? another_assignment.volunteer.contact.full_name, href: volunteer_path(another_assignment.volunteer)
refute page.has_link? another_group_assignment.to_label, href: group_offer_path(another_group_assignment.group_offer)
refute page.has_link? another_group_assignment.volunteer.contact.full_name, href: volunteer_path(another_group_assignment.volunteer)
assert page.has_link? assignment.to_label,
href: assignment_path(assignment)
assert page.has_link? assignment.volunteer.contact.full_name,
href: volunteer_path(assignment.volunteer)
assert page.has_link? group_assignment.to_label,
href: group_offer_path(group_assignment.group_offer)
assert page.has_link? group_assignment.volunteer.contact.full_name,
href: volunteer_path(group_assignment.volunteer)
refute page.has_link? another_assignment.to_label,
href: assignment_path(another_assignment)
refute page.has_link? another_assignment.volunteer.contact.full_name,
href: volunteer_path(another_assignment.volunteer)
refute page.has_link? another_group_assignment.to_label,
href: group_offer_path(another_group_assignment.group_offer)
refute page.has_link? another_group_assignment.volunteer.contact.full_name,
href: volunteer_path(another_group_assignment.volunteer)
refute page.has_link? terminated_assignment.to_label,
href: assignment_path(terminated_assignment)
refute page.has_link? terminated_assignment.volunteer.contact.full_name,
href: volunteer_path(terminated_assignment.volunteer)
refute page.has_link? terminated_group_assignment.to_label,
href: group_offer_path(terminated_group_assignment.group_offer)
refute page.has_link? terminated_group_assignment.volunteer.contact.full_name,
href: volunteer_path(terminated_group_assignment.volunteer)
# All checkboxes are not checked?
refute page.find_all(
......
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