Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/mailers/form_submission_confirmation_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
31 changes: 31 additions & 0 deletions spec/mailers/form_submission_confirmation_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/requests/forms/check_your_answers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down