|
30 | 30 | submission_locale: "en", |
31 | 31 | ) |
32 | 32 | end |
33 | | - let(:notify_response_id) { "confirmation-ref" } |
34 | 33 | let(:confirmation_email_address) { "testing@gov.uk" } |
35 | 34 |
|
36 | 35 | context "when include_copy_of_answers is false" do |
|
43 | 42 | expect { |
44 | 43 | described_class.perform_now( |
45 | 44 | submission:, |
46 | | - notify_response_id:, |
47 | 45 | confirmation_email_address:, |
48 | 46 | ) |
49 | 47 | }.to change(ActionMailer::Base.deliveries, :count).by(1) |
|
53 | 51 | end |
54 | 52 |
|
55 | 53 | it "builds mailer arguments from the submission" do |
56 | | - allow(FormSubmissionConfirmationMailer).to receive(:send_confirmation_email).and_call_original |
| 54 | + allow(AwsSesSubmissionConfirmationMailer).to receive(:submission_confirmation_email).and_call_original |
57 | 55 |
|
58 | 56 | described_class.perform_now( |
59 | 57 | submission:, |
60 | | - notify_response_id:, |
61 | 58 | confirmation_email_address:, |
62 | 59 | ) |
63 | 60 |
|
64 | | - expect(FormSubmissionConfirmationMailer).to have_received(:send_confirmation_email).with( |
| 61 | + expect(AwsSesSubmissionConfirmationMailer).to have_received(:submission_confirmation_email).with( |
65 | 62 | submission:, |
66 | | - notify_response_id: "confirmation-ref", |
67 | 63 | confirmation_email_address: "testing@gov.uk", |
| 64 | + include_copy_of_answers: false, |
68 | 65 | ) |
69 | 66 | end |
70 | | - |
71 | | - context "when submission locale is Welsh" do |
72 | | - let(:welsh_form_document) { build(:v2_form_document, name: "Welsh Form") } |
73 | | - |
74 | | - before do |
75 | | - submission.update!(submission_locale: "cy") |
76 | | - allow(Api::V2::FormDocumentRepository).to receive(:find_with_mode).and_call_original |
77 | | - allow(Api::V2::FormDocumentRepository).to receive(:find_with_mode).with( |
78 | | - form_id: anything, |
79 | | - mode: anything, |
80 | | - language: :cy, |
81 | | - ).and_return(welsh_form_document) |
82 | | - end |
83 | | - |
84 | | - it "uses the bilingual template" do |
85 | | - described_class.perform_now( |
86 | | - submission:, |
87 | | - notify_response_id:, |
88 | | - confirmation_email_address:, |
89 | | - ) |
90 | | - |
91 | | - mail = ActionMailer::Base.deliveries.last |
92 | | - expect(mail.govuk_notify_template).to eq("7891011") |
93 | | - end |
94 | | - end |
95 | 67 | end |
96 | 68 |
|
97 | 69 | context "when include_copy_of_answers is true" do |
98 | 70 | it "sends the confirmation email including the answers" do |
99 | 71 | expect { |
100 | 72 | described_class.perform_now( |
101 | 73 | submission:, |
102 | | - notify_response_id:, |
103 | 74 | confirmation_email_address:, |
104 | 75 | include_copy_of_answers: true, |
105 | 76 | ) |
|
115 | 86 | I18n.with_locale(:cy) do |
116 | 87 | described_class.perform_now( |
117 | 88 | submission:, |
118 | | - notify_response_id:, |
119 | 89 | confirmation_email_address:, |
120 | 90 | include_copy_of_answers: true, |
121 | 91 | ) |
|
148 | 118 | it "passes the confirmation email configuration set name to SES" do |
149 | 119 | described_class.perform_now( |
150 | 120 | submission:, |
151 | | - notify_response_id:, |
152 | 121 | confirmation_email_address:, |
153 | 122 | include_copy_of_answers: true, |
154 | 123 | ) |
|
162 | 131 |
|
163 | 132 | context "when there is an error during processing" do |
164 | 133 | before do |
165 | | - allow(FormSubmissionConfirmationMailer).to receive(:send_confirmation_email).and_raise(StandardError, "Test error") |
| 134 | + allow(AwsSesSubmissionConfirmationMailer).to receive(:submission_confirmation_email).and_raise(StandardError, "Test error") |
166 | 135 | allow(CloudWatchService).to receive(:record_job_failure_metric) |
167 | 136 | end |
168 | 137 |
|
169 | 138 | it "raises an error" do |
170 | 139 | expect { |
171 | 140 | described_class.perform_now( |
172 | 141 | submission:, |
173 | | - notify_response_id:, |
174 | 142 | confirmation_email_address:, |
175 | 143 | ) |
176 | 144 | }.to raise_error(StandardError, "Test error") |
|
179 | 147 | it "sends cloudwatch metric for failure" do |
180 | 148 | described_class.perform_now( |
181 | 149 | submission:, |
182 | | - notify_response_id:, |
183 | 150 | confirmation_email_address:, |
184 | 151 | ) |
185 | 152 | expect(CloudWatchService).to have_received(:record_job_failure_metric).with("SendConfirmationEmailJob") |
|
0 commit comments