From 76ac54ada5f8d8682195e6a7ab30c6e15280533c Mon Sep 17 00:00:00 2001 From: chao-xian Date: Wed, 20 May 2026 13:26:05 +0100 Subject: [PATCH] Add missing Welsh personalisations for confirmation email --- .../form_submission_confirmation_mailer.rb | 4 ++- ...orm_submission_confirmation_mailer_spec.rb | 31 +++++++++++++++++++ .../check_your_answers_controller_spec.rb | 2 ++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/app/mailers/form_submission_confirmation_mailer.rb b/app/mailers/form_submission_confirmation_mailer.rb index 195f2107a..5abbb8f82 100644 --- a/app/mailers/form_submission_confirmation_mailer.rb +++ b/app/mailers/form_submission_confirmation_mailer.rb @@ -8,6 +8,7 @@ def send_confirmation_email(form:, welsh_form:, submission:, notify_response_id: what_happens_next_text = form.what_happens_next_markdown.presence || default_what_happens_next_text set_personalisation( title: form.name, + title_cy: welsh_form&.name || form.name, what_happens_next_text:, what_happens_next_text_cy: welsh_form&.what_happens_next_markdown.presence || what_happens_next_text, support_contact_details: format_support_details(form.support_details).presence || default_support_contact_details_text, @@ -18,7 +19,8 @@ def send_confirmation_email(form:, welsh_form:, submission:, notify_response_id: test: make_notify_boolean(submission.preview?), submission_reference: submission.reference, include_payment_link: make_notify_boolean(submission.payment_url.present?), - payment_link: submission.payment_url || "", + payment_link: form.payment_url_with_reference(submission.reference) || "", + payment_link_cy: welsh_form&.payment_url_with_reference(submission.reference) || "", ) set_reference(notify_response_id) diff --git a/spec/mailers/form_submission_confirmation_mailer_spec.rb b/spec/mailers/form_submission_confirmation_mailer_spec.rb index 8062ebb5d..d0c784489 100644 --- a/spec/mailers/form_submission_confirmation_mailer_spec.rb +++ b/spec/mailers/form_submission_confirmation_mailer_spec.rb @@ -53,6 +53,20 @@ expect(mail.govuk_notify_personalisation[:title]).to eq(form.name) end + context "when no Welsh form is provided" do + it "falls back to the English title for title_cy" do + expect(mail.govuk_notify_personalisation[:title_cy]).to eq(form.name) + end + end + + context "when a Welsh form is provided" do + let(:welsh_form) { Form.new(build(:v2_form_document, name: "Ffurflen 1")) } + + it "uses the Welsh form name as title_cy" do + expect(mail.govuk_notify_personalisation[:title_cy]).to eq("Ffurflen 1") + end + end + it "includes the forms what happens next" do expect(mail.govuk_notify_personalisation[:what_happens_next_text]).to eq("Please wait for a response") end @@ -104,6 +118,19 @@ it "sets the payment_link" do expect(mail.govuk_notify_personalisation[:payment_link]).to eq("#{payment_url}?reference=#{submission_reference}") end + + it "sets payment_link_cy to an empty string when no Welsh form is provided" do + expect(mail.govuk_notify_personalisation[:payment_link_cy]).to eq("") + end + + context "when the Welsh form has a payment url" do + let(:welsh_payment_url) { "https://www.gov.uk/payments/welsh-service/pay-for-licence" } + let(:welsh_form) { Form.new(build(:v2_form_document, payment_url: welsh_payment_url)) } + + it "sets payment_link_cy to the Welsh payment url with reference" do + expect(mail.govuk_notify_personalisation[:payment_link_cy]).to eq("#{welsh_payment_url}?reference=#{submission_reference}") + end + end end context "when a payment url is not set" do @@ -116,6 +143,10 @@ it "sets the payment link personalisation to an empty string" do expect(mail.govuk_notify_personalisation[:payment_link]).to eq("") end + + it "sets the Welsh payment link personalisation to an empty string" do + expect(mail.govuk_notify_personalisation[:payment_link_cy]).to eq("") + end end context "when submission_locale is :en" do diff --git a/spec/requests/forms/check_your_answers_controller_spec.rb b/spec/requests/forms/check_your_answers_controller_spec.rb index f31528a01..60b12cc6f 100644 --- a/spec/requests/forms/check_your_answers_controller_spec.rb +++ b/spec/requests/forms/check_your_answers_controller_spec.rb @@ -496,6 +496,7 @@ expected_personalisation = { title: form_data.name, + title_cy: form_data.name, what_happens_next_text: form_data.what_happens_next_markdown, what_happens_next_text_cy: form_data.what_happens_next_markdown, support_contact_details: contact_support_details_format, @@ -507,6 +508,7 @@ submission_reference: reference, include_payment_link: "no", payment_link: "", + payment_link_cy: "", } expect(mail.body.raw_source).to include(expected_personalisation.to_s)