|
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 |
|
173 | 159 | expect(EventLogger).not_to have_received(:log) |
174 | 160 | end |
175 | 161 |
|
176 | | - include_examples "for notification references" |
177 | 162 | end |
178 | 163 | end |
179 | 164 |
|
|
195 | 180 | expect(EventLogger).to have_received(:log_form_event).with("check_answers") |
196 | 181 | end |
197 | 182 |
|
198 | | - include_examples "for notification references" |
199 | 183 | end |
200 | 184 | end |
201 | 185 | end |
|
209 | 193 | ) |
210 | 194 | end |
211 | 195 |
|
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 | 196 | context "with preview mode on" do |
219 | 197 | let(:mode) { "preview-live" } |
220 | 198 |
|
|
243 | 221 | it "includes the confirmation_email_id in the logging context" do |
244 | 222 | expect(log_lines.last["confirmation_email_id"]).to eq(confirmation_email_id) |
245 | 223 | end |
246 | | - |
247 | | - include_examples "for notification references" |
248 | 224 | end |
249 | 225 |
|
250 | 226 | context "with preview mode off" do |
|
275 | 251 | it "includes the confirmation_email_id in the logging context" do |
276 | 252 | expect(log_lines.last["confirmation_email_id"]).to eq(confirmation_email_id) |
277 | 253 | end |
278 | | - |
279 | | - include_examples "for notification references" |
280 | 254 | end |
281 | 255 |
|
282 | 256 | context "when the submission type is s3" do |
|
359 | 333 | let(:email_confirmation_input) do |
360 | 334 | { |
361 | 335 | send_confirmation: nil, |
362 | | - confirmation_email_reference:, |
363 | 336 | } |
364 | 337 | end |
365 | 338 |
|
|
375 | 348 | expect(response).to render_template("forms/check_your_answers/show") |
376 | 349 | end |
377 | 350 |
|
378 | | - it "does not generate a new submission reference" do |
379 | | - expect(response.body).to include confirmation_email_reference |
| 351 | + it "does not render a hidden confirmation reference field" do |
| 352 | + expect(response.body).not_to include("confirmation-email-reference") |
380 | 353 | end |
381 | 354 | end |
382 | 355 |
|
|
385 | 358 | { |
386 | 359 | send_confirmation: "send_email", |
387 | 360 | confirmation_email_address: nil, |
388 | | - confirmation_email_reference:, |
389 | 361 | } |
390 | 362 | end |
391 | 363 |
|
|
401 | 373 | expect(response).to render_template("forms/check_your_answers/show") |
402 | 374 | end |
403 | 375 |
|
404 | | - it "does not generate a new submission reference" do |
405 | | - expect(response.body).to include confirmation_email_reference |
| 376 | + it "does not render a hidden confirmation reference field" do |
| 377 | + expect(response.body).not_to include("confirmation-email-reference") |
406 | 378 | end |
407 | 379 |
|
408 | | - include_examples "for notification references" |
409 | 380 | end |
410 | 381 |
|
411 | 382 | context "when user has not requested a confirmation email" do |
412 | 383 | let(:email_confirmation_input) do |
413 | 384 | { |
414 | 385 | send_confirmation: "skip_confirmation", |
415 | 386 | confirmation_email_address: nil, |
416 | | - confirmation_email_reference:, |
417 | 387 | } |
418 | 388 | end |
419 | 389 |
|
|
424 | 394 | it "redirects to confirmation page" do |
425 | 395 | expect(response).to redirect_to(form_submitted_path) |
426 | 396 | 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 | 397 | end |
436 | 398 |
|
437 | 399 | context "when user has requested a confirmation email" do |
438 | 400 | let(:email_confirmation_input) do |
439 | 401 | { send_confirmation: "send_email", |
440 | | - confirmation_email_address: Faker::Internet.email, |
441 | | - confirmation_email_reference: } |
| 402 | + confirmation_email_address: Faker::Internet.email } |
442 | 403 | end |
443 | 404 |
|
444 | 405 | before do |
|
474 | 435 |
|
475 | 436 | expect(mail.body.raw_source).to include(expected_personalisation.to_s) |
476 | 437 |
|
477 | | - expect(mail.govuk_notify_reference).to eq confirmation_email_reference |
| 438 | + expect(mail.govuk_notify_reference).to eq generated_confirmation_email_reference |
478 | 439 | end |
479 | 440 |
|
480 | 441 | it "includes the confirmation_email_id in the logging context" do |
481 | 442 | expect(log_lines.last["confirmation_email_id"]).to eq(confirmation_email_id) |
482 | 443 | end |
483 | | - |
484 | | - include_examples "for notification references" |
485 | 444 | end |
486 | 445 |
|
487 | 446 | context "when there is a submission error" do |
488 | 447 | let(:email_confirmation_input) do |
489 | 448 | { send_confirmation: "send_email", |
490 | | - confirmation_email_address: Faker::Internet.email, |
491 | | - confirmation_email_reference: } |
| 449 | + confirmation_email_address: Faker::Internet.email } |
492 | 450 | end |
493 | 451 |
|
494 | 452 | before do |
|
511 | 469 | it "returns 500" do |
512 | 470 | expect(response).to have_http_status(:internal_server_error) |
513 | 471 | end |
514 | | - |
515 | | - include_examples "for notification references" |
516 | 472 | end |
517 | 473 |
|
518 | 474 | context "when there is an ActionMailer error with the confirmation email address" do |
|
0 commit comments