Skip to content

Commit 9e52742

Browse files
authored
Merge pull request #2112 from govuk-forms/welsh-confirmation
Add missing Welsh personalisations for confirmation email
2 parents 214a820 + 76ac54a commit 9e52742

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

app/mailers/form_submission_confirmation_mailer.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def send_confirmation_email(form:, welsh_form:, submission:, notify_response_id:
88
what_happens_next_text = form.what_happens_next_markdown.presence || default_what_happens_next_text
99
set_personalisation(
1010
title: form.name,
11+
title_cy: welsh_form&.name || form.name,
1112
what_happens_next_text:,
1213
what_happens_next_text_cy: welsh_form&.what_happens_next_markdown.presence || what_happens_next_text,
1314
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:
1819
test: make_notify_boolean(submission.preview?),
1920
submission_reference: submission.reference,
2021
include_payment_link: make_notify_boolean(submission.payment_url.present?),
21-
payment_link: submission.payment_url || "",
22+
payment_link: form.payment_url_with_reference(submission.reference) || "",
23+
payment_link_cy: welsh_form&.payment_url_with_reference(submission.reference) || "",
2224
)
2325

2426
set_reference(notify_response_id)

spec/mailers/form_submission_confirmation_mailer_spec.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@
5353
expect(mail.govuk_notify_personalisation[:title]).to eq(form.name)
5454
end
5555

56+
context "when no Welsh form is provided" do
57+
it "falls back to the English title for title_cy" do
58+
expect(mail.govuk_notify_personalisation[:title_cy]).to eq(form.name)
59+
end
60+
end
61+
62+
context "when a Welsh form is provided" do
63+
let(:welsh_form) { Form.new(build(:v2_form_document, name: "Ffurflen 1")) }
64+
65+
it "uses the Welsh form name as title_cy" do
66+
expect(mail.govuk_notify_personalisation[:title_cy]).to eq("Ffurflen 1")
67+
end
68+
end
69+
5670
it "includes the forms what happens next" do
5771
expect(mail.govuk_notify_personalisation[:what_happens_next_text]).to eq("Please wait for a response")
5872
end
@@ -104,6 +118,19 @@
104118
it "sets the payment_link" do
105119
expect(mail.govuk_notify_personalisation[:payment_link]).to eq("#{payment_url}?reference=#{submission_reference}")
106120
end
121+
122+
it "sets payment_link_cy to an empty string when no Welsh form is provided" do
123+
expect(mail.govuk_notify_personalisation[:payment_link_cy]).to eq("")
124+
end
125+
126+
context "when the Welsh form has a payment url" do
127+
let(:welsh_payment_url) { "https://www.gov.uk/payments/welsh-service/pay-for-licence" }
128+
let(:welsh_form) { Form.new(build(:v2_form_document, payment_url: welsh_payment_url)) }
129+
130+
it "sets payment_link_cy to the Welsh payment url with reference" do
131+
expect(mail.govuk_notify_personalisation[:payment_link_cy]).to eq("#{welsh_payment_url}?reference=#{submission_reference}")
132+
end
133+
end
107134
end
108135

109136
context "when a payment url is not set" do
@@ -116,6 +143,10 @@
116143
it "sets the payment link personalisation to an empty string" do
117144
expect(mail.govuk_notify_personalisation[:payment_link]).to eq("")
118145
end
146+
147+
it "sets the Welsh payment link personalisation to an empty string" do
148+
expect(mail.govuk_notify_personalisation[:payment_link_cy]).to eq("")
149+
end
119150
end
120151

121152
context "when submission_locale is :en" do

spec/requests/forms/check_your_answers_controller_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@
496496

497497
expected_personalisation = {
498498
title: form_data.name,
499+
title_cy: form_data.name,
499500
what_happens_next_text: form_data.what_happens_next_markdown,
500501
what_happens_next_text_cy: form_data.what_happens_next_markdown,
501502
support_contact_details: contact_support_details_format,
@@ -507,6 +508,7 @@
507508
submission_reference: reference,
508509
include_payment_link: "no",
509510
payment_link: "",
511+
payment_link_cy: "",
510512
}
511513

512514
expect(mail.body.raw_source).to include(expected_personalisation.to_s)

0 commit comments

Comments
 (0)