-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send confirmation email when leaving zusatzsektion
- Loading branch information
Showing
5 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024, Schweizer Alpen-Club. This file is part of | ||
# hitobito_sac_cas and licensed under the Affero General Public License version 3 | ||
# or later. See the COPYING file at the top-level directory or at | ||
# https://github.com/hitobito/hitobito_sac_cas. | ||
|
||
module Memberships | ||
class LeaveZusatzsektionMailer < ApplicationMailer | ||
CONFIRMATION = "memberships_leave_zusatzsektion_confirmation" | ||
|
||
def confirmation(person, sektion_name, terminate_on) | ||
values = [ | ||
%W[person-name #{person}], | ||
%W[sektion-name #{sektion_name}], | ||
%W[terminate-on #{terminate_on}] | ||
].to_h | ||
custom_headers = {cc: Group::Geschaeftsstelle.first.email} | ||
custom_content_mail([person], CONFIRMATION, values, custom_headers) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
spec/mailers/memberships/leave_zusatzsektion_mailer_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024, Schweizer Alpen-Club. This file is part of | ||
# hitobito_sac_cas and licensed under the Affero General Public License version 3 | ||
# or later. See the COPYING file at the top-level directory or at | ||
# https://github.com/hitobito/hitobito_sac_cas. | ||
# | ||
require "spec_helper" | ||
|
||
describe Memberships::LeaveZusatzsektionMailer do | ||
let(:person) { people(:mitglied) } | ||
let(:group) { groups(:bluemlisalp) } | ||
let(:switch_on) { "sofort" } | ||
let(:mail) { described_class.confirmation(person, group, switch_on) } | ||
|
||
subject { mail.parts.first.body } | ||
|
||
it "sends confirmation email to person" do | ||
expect(mail.to).to match_array(["e.hillary@hitobito.example.com"]) | ||
expect(mail.subject).to eq "Bestätigung Austritt Zusatzsektion" | ||
expect(mail.body).to match("Hallo Edmund Hillary,") | ||
expect(mail.body).to match("Der Austritt aus SAC Blüemlisalp wurde per sofort vorgenommen.") | ||
end | ||
|
||
it "sends confirmation email to geschaefsstelle if configured" do | ||
groups(:geschaeftsstelle).update!(email: "geschaeftsstelle@example.com") | ||
expect(mail.cc).to eq ["geschaeftsstelle@example.com"] | ||
end | ||
end |