|
23 | 23 |
|
24 | 24 | let(:email_confirmation_input) do |
25 | 25 | { send_confirmation: "send_email", |
26 | | - confirmation_email_address: Faker::Internet.email, |
27 | | - confirmation_email_reference: } |
| 26 | + confirmation_email_address: Faker::Internet.email } |
28 | 27 | end |
29 | 28 |
|
30 | 29 | let(:submission_email) { Faker::Internet.email(domain: "example.gov.uk") } |
|
87 | 86 |
|
88 | 87 | let(:reference) { Faker::Alphanumeric.alphanumeric(number: 8).upcase } |
89 | 88 | let(:confirmation_email_id) { "2222" } |
90 | | - let(:confirmation_email_reference) { "confirmation-email-ref" } |
| 89 | + let(:generated_confirmation_email_reference) { "generated-confirmation-uuid-confirmation-email" } |
91 | 90 |
|
92 | 91 | before do |
93 | 92 | ActiveResource::HttpMock.respond_to do |mock| |
|
101 | 100 | end |
102 | 101 |
|
103 | 102 | allow(ReferenceNumberService).to receive(:generate).and_return(reference) |
| 103 | + allow(SecureRandom).to receive(:uuid).and_return("generated-confirmation-uuid") |
104 | 104 | end |
105 | 105 |
|
106 | 106 | describe "#show" do |
107 | | - shared_examples "for notification references" do |
108 | | - prepend_before do |
109 | | - allow(EmailConfirmationInput).to receive(:new).and_wrap_original do |original_method, *args| |
110 | | - double = original_method.call(*args) |
111 | | - allow(double).to receive_messages(confirmation_email_reference:) |
112 | | - double |
113 | | - end |
114 | | - end |
115 | | - |
116 | | - it "includes a notification reference for the confirmation email" do |
117 | | - expect(response.body).to include confirmation_email_reference |
118 | | - end |
119 | | - end |
120 | | - |
121 | 107 | shared_examples "for redirecting if the form is incomplete" do |
122 | 108 | context "without any questions answered" do |
123 | 109 | let(:store) do |
|
172 | 158 | it "does not log the form_check_answers event" do |
173 | 159 | expect(EventLogger).not_to have_received(:log) |
174 | 160 | end |
175 | | - |
176 | | - include_examples "for notification references" |
177 | 161 | end |
178 | 162 | end |
179 | 163 |
|
|
194 | 178 | it "Logs the form_check_answers event" do |
195 | 179 | expect(EventLogger).to have_received(:log_form_event).with("check_answers") |
196 | 180 | end |
197 | | - |
198 | | - include_examples "for notification references" |
199 | 181 | end |
200 | 182 | end |
201 | 183 | end |
|
209 | 191 | ) |
210 | 192 | end |
211 | 193 |
|
212 | | - shared_examples "for notification references" do |
213 | | - it "includes the confirmation_email_reference in the logging_context" do |
214 | | - expect(log_line["confirmation_email_reference"]).to eq(confirmation_email_reference) |
215 | | - end |
216 | | - end |
217 | | - |
218 | 194 | context "with preview mode on" do |
219 | 195 | let(:mode) { "preview-live" } |
220 | 196 |
|
|
243 | 219 | it "includes the confirmation_email_id in the logging context" do |
244 | 220 | expect(log_lines.last["confirmation_email_id"]).to eq(confirmation_email_id) |
245 | 221 | end |
246 | | - |
247 | | - include_examples "for notification references" |
248 | 222 | end |
249 | 223 |
|
250 | 224 | context "with preview mode off" do |
|
275 | 249 | it "includes the confirmation_email_id in the logging context" do |
276 | 250 | expect(log_lines.last["confirmation_email_id"]).to eq(confirmation_email_id) |
277 | 251 | end |
278 | | - |
279 | | - include_examples "for notification references" |
280 | 252 | end |
281 | 253 |
|
282 | 254 | context "when the submission type is s3" do |
|
359 | 331 | let(:email_confirmation_input) do |
360 | 332 | { |
361 | 333 | send_confirmation: nil, |
362 | | - confirmation_email_reference:, |
363 | 334 | } |
364 | 335 | end |
365 | 336 |
|
|
375 | 346 | expect(response).to render_template("forms/check_your_answers/show") |
376 | 347 | end |
377 | 348 |
|
378 | | - it "does not generate a new submission reference" do |
379 | | - expect(response.body).to include confirmation_email_reference |
| 349 | + it "does not render a hidden confirmation reference field" do |
| 350 | + expect(response.body).not_to include("confirmation-email-reference") |
380 | 351 | end |
381 | 352 | end |
382 | 353 |
|
|
385 | 356 | { |
386 | 357 | send_confirmation: "send_email", |
387 | 358 | confirmation_email_address: nil, |
388 | | - confirmation_email_reference:, |
389 | 359 | } |
390 | 360 | end |
391 | 361 |
|
|
401 | 371 | expect(response).to render_template("forms/check_your_answers/show") |
402 | 372 | end |
403 | 373 |
|
404 | | - it "does not generate a new submission reference" do |
405 | | - expect(response.body).to include confirmation_email_reference |
| 374 | + it "does not render a hidden confirmation reference field" do |
| 375 | + expect(response.body).not_to include("confirmation-email-reference") |
406 | 376 | end |
407 | | - |
408 | | - include_examples "for notification references" |
409 | 377 | end |
410 | 378 |
|
411 | 379 | context "when user has not requested a confirmation email" do |
412 | 380 | let(:email_confirmation_input) do |
413 | 381 | { |
414 | 382 | send_confirmation: "skip_confirmation", |
415 | 383 | confirmation_email_address: nil, |
416 | | - confirmation_email_reference:, |
417 | 384 | } |
418 | 385 | end |
419 | 386 |
|
|
424 | 391 | it "redirects to confirmation page" do |
425 | 392 | expect(response).to redirect_to(form_submitted_path) |
426 | 393 | end |
427 | | - |
428 | | - it "does not include the confirmation_email_id in the logging context" do |
429 | | - expect(log_line.keys).not_to include("confirmation_email_id") |
430 | | - end |
431 | | - |
432 | | - it "does not include confirmation_email_reference in logging context" do |
433 | | - expect(log_line.keys).not_to include("confirmation_email_reference") |
434 | | - end |
435 | 394 | end |
436 | 395 |
|
437 | 396 | context "when user has requested a confirmation email" do |
438 | 397 | let(:email_confirmation_input) do |
439 | 398 | { send_confirmation: "send_email", |
440 | | - confirmation_email_address: Faker::Internet.email, |
441 | | - confirmation_email_reference: } |
| 399 | + confirmation_email_address: Faker::Internet.email } |
442 | 400 | end |
443 | 401 |
|
444 | 402 | before do |
|
474 | 432 |
|
475 | 433 | expect(mail.body.raw_source).to include(expected_personalisation.to_s) |
476 | 434 |
|
477 | | - expect(mail.govuk_notify_reference).to eq confirmation_email_reference |
| 435 | + expect(mail.govuk_notify_reference).to eq generated_confirmation_email_reference |
478 | 436 | end |
479 | 437 |
|
480 | 438 | it "includes the confirmation_email_id in the logging context" do |
481 | 439 | expect(log_lines.last["confirmation_email_id"]).to eq(confirmation_email_id) |
482 | 440 | end |
483 | | - |
484 | | - include_examples "for notification references" |
485 | 441 | end |
486 | 442 |
|
487 | 443 | context "when there is a submission error" do |
488 | 444 | let(:email_confirmation_input) do |
489 | 445 | { send_confirmation: "send_email", |
490 | | - confirmation_email_address: Faker::Internet.email, |
491 | | - confirmation_email_reference: } |
| 446 | + confirmation_email_address: Faker::Internet.email } |
492 | 447 | end |
493 | 448 |
|
494 | 449 | before do |
|
511 | 466 | it "returns 500" do |
512 | 467 | expect(response).to have_http_status(:internal_server_error) |
513 | 468 | end |
514 | | - |
515 | | - include_examples "for notification references" |
516 | 469 | end |
517 | 470 |
|
518 | 471 | context "when there is an ActionMailer error with the confirmation email address" do |
|
0 commit comments