Commit 5616fb1d authored by Tugce Nur Tas's avatar Tugce Nur Tas
Browse files

Merge branch 'features/group-assignment-notification-after-termination' into 'develop'

Features/Mail nach Submit Formular zur Beendigung eines Freiwilligen in einem Gruppenangebot

See merge request !469
parents 57bbfe52 991cff5e
Pipeline #13994 passed with stage
in 32 minutes and 29 seconds
......@@ -101,10 +101,8 @@ class AssignmentsController < ApplicationController
@assignment.volunteer.waive = assignment_params[:volunteer_attributes][:waive] == '1'
@assignment.assign_attributes(termination_submitted_at: Time.zone.now,
termination_submitted_by: current_user)
if @assignment.save && terminate_reminder_mailing
NotificationMailer.termination_submitted(@assignment).deliver_now
redirect_to @assignment.volunteer, notice: 'Der Einsatz ist hiermit abgeschlossen.'
else
redirect_back(fallback_location: terminate_assignment_path(@assignment))
......
......@@ -60,6 +60,7 @@ class GroupAssignmentsController < ApplicationController
@group_assignment.assign_attributes(group_assignment_params.except(:volunteer_attributes)
.merge(termination_submitted_at: Time.zone.now, termination_submitted_by: current_user))
if @group_assignment.save && terminate_reminder_mailing
NotificationMailer.termination_submitted(@group_assignment).deliver_now
redirect_to @group_assignment.volunteer,
notice: 'Der Gruppeneinsatz ist hiermit abgeschlossen.'
else
......@@ -100,7 +101,6 @@ class GroupAssignmentsController < ApplicationController
ReminderMailingVolunteer.termination_for(@group_assignment).map do |rmv|
rmv.mark_process_submitted(current_user, terminate_parent_mailing: true)
end
NotificationMailer.termination_submitted(@group_assignment).deliver_now
end
def set_group_assignment
......
class NotificationMailer < ApplicationMailer
def termination_submitted(assignment)
@assignment = assignment
@assignment = @group_assignment = assignment
@subject = 'Beendigung des Einsatzes bestätigt durch ' +
@assignment.termination_submitted_by.email
assignment.termination_submitted_by.email
mail(to: assignment.period_end_set_by&.email || assignment.creator.email, subject: @subject)
end
......
h1= @subject
= link_to 'Zur Übersicht der beendeten Einsätze', terminated_index_assignments_url
- 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
<%= @subject %>
Zur Übersicht der beendeten Einsätze:
<%= url_for(terminated_index_assignments_url) %>
- 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) %>
......@@ -102,4 +102,17 @@ class GroupAssignmentTerminatesTest < ApplicationSystemTestCase
assert page.has_text? 'my_newly_added_feedback_comment_text'
end
end
test 'termination triggers notification email to creator' do
ActionMailer::Base.deliveries.clear
@group_assignment.update(period_end: 2.days.ago)
login_as @volunteer.user
visit terminate_group_assignment_path(@group_assignment)
page.accept_confirm do
click_button 'Einsatz wird hiermit abgeschlossen'
end
mail = ActionMailer::Base.deliveries.last
assert_equal @superadmin.email, mail['to'].to_s
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