termination notification mailer has link with correct filter

parent a7ac2286
Pipeline #43397 passed with stage
in 38 minutes and 35 seconds
class NotificationMailer < ApplicationMailer
def termination_submitted(assignment)
@assignment = @group_assignment = assignment
@subject = 'Beendigung des Einsatzes bestätigt durch ' +
assignment.termination_submitted_by.email
mail(to: assignment.period_end_set_by&.email || assignment.creator.email, subject: @subject)
def termination_submitted(terminated)
@terminated = terminated
@link_params = { q: { termination_verified_by_id_not_null: 'true' } }
mail(
to: terminated.period_end_set_by&.email || terminated.creator.email,
subject: I18n.t(
'notification_mailer.termination_submitted.subject',
email: @terminated.termination_submitted_by.email
)
)
end
end
h1= @subject
h1= t('.title', email: @terminated.termination_submitted_by.email)
- if @assignment
= link_to 'Zur Übersicht der beendeten Einsätzen', terminated_index_assignments_url
- else
= link_to 'Zur Übersicht der beendeten Gruppeninsätzen', terminated_index_group_assignments_url
- if @terminated.assignment?
p= link_to t('.link_text.terminated_assignment'), terminated_index_assignments_url(@link_params)
- elsif @terminated.group_assignment?
p= link_to t('.link_text.terminated_group_assignment'), terminated_index_group_assignments_url(@link_params)
p AOZ Fachstelle Freiwilligenarbeit
<%= @subject %>
<%= t('.title', email: @terminated.termination_submitted_by.email) %>
- if @assignment
Zur Übersicht der beendeten Einsätzen:
<%= url_for(terminated_index_assignments_url) %>
- else
Zur Übersicht der beendeten Gruppeneinsätzen:
<%= url_for(terminated_index_group_assignments_url) %>
<% if @terminated.assignment? %>
<%= t('.link_text.terminated_assignment') %>:
<%= url_for(terminated_index_assignments_url(@link_params)) %>
<% elsif @terminated.group_assignment? %>
<%= t('.link_text.terminated_group_assignment') %>:
<%= url_for(terminated_index_group_assignments_url(@link_params)) %>
<% end %>
AOZ Fachstelle Freiwilligenarbeit
......@@ -623,6 +623,14 @@ de:
volunteer_application: Freiwilligen Anmeldung
# model name plural for controller name shortcut => t('.key')
notification_mailer:
termination_submitted:
title: 'Beendigung des Einsatzes bestätigt durch %{email}'
subject: 'Beendigung des Einsatzes bestätigt durch %{email}'
assignment:
link_text:
terminated_assignment: Zur Übersicht der beendeten Einsätze
terminated_group_assignment: Zur Übersicht der beendeten Gruppeninsätze
assignment_pdf:
<<: *id-generic_keys
birthdate: Geburtsdatum
......
......@@ -10,6 +10,10 @@ FactoryBot.define do
user.profile&.user = user
end
trait :superadmin do
role User::SUPERADMIN
end
trait :social_worker do
role User::SOCIAL_WORKER
end
......@@ -38,6 +42,7 @@ FactoryBot.define do
profile {}
end
factory :superadmin, traits: [:superadmin]
factory :social_worker, traits: [:social_worker]
factory :department_manager, traits: [:department_manager, :with_department]
factory :department_manager_without_department, traits: [:department_manager]
......
require 'test_helper'
class NotificationMailerest < ActionMailer::TestCase
def setup
@superadmin = create :superadmin
@other_superadmin = create :superadmin
end
test 'termination_submitted assignment' do
assignment = create :terminated_assignment, creator: @superadmin
assignment.update!(termination_submitted_by: @other_superadmin, period_end_set_by: @superadmin)
mailer = NotificationMailer.termination_submitted(assignment).deliver
assert_includes mailer.to, @superadmin.email
text = mailer.text_part.body.decoded
html = mailer.html_part.body.decoded
assert_match @other_superadmin.email, text
assert_match @other_superadmin.email, html
assert_match '/assignments/terminated_index?q%5Btermination_verified_by_id_not_null%5D=true', text
assert_match '/assignments/terminated_index?q%5Btermination_verified_by_id_not_null%5D=true', html
end
test 'termination_submitted group_assignment' do
group_assignment = create :terminated_group_assignment, creator: @superadmin
group_assignment.update!(termination_submitted_by: @other_superadmin, period_end_set_by: @superadmin)
mailer = NotificationMailer.termination_submitted(group_assignment).deliver
assert_includes mailer.to, @superadmin.email
text = mailer.text_part.body.decoded
html = mailer.html_part.body.decoded
assert_match @other_superadmin.email, text
assert_match @other_superadmin.email, html
assert_match '/group_assignments/terminated_index?q%5Btermination_verified_by_id_not_null%5D=true', text
assert_match '/group_assignments/terminated_index?q%5Btermination_verified_by_id_not_null%5D=true', html
end
end
Markdown is supported
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