diff --git a/app/models/question/file.rb b/app/models/question/file.rb index 5340a34e0..3d94dbf16 100644 --- a/app/models/question/file.rb +++ b/app/models/question/file.rb @@ -32,6 +32,12 @@ def show_answer original_filename end + def show_answer_in_email + return nil if original_filename.blank? + + I18n.t("mailer.submission.file_attached", filename: original_filename) + end + def before_save if file.blank? # set to a blank string so that we serialize the answer correctly when an optional question isn't answered diff --git a/app/views/aws_ses_form_submission_mailer/submission_email.html.erb b/app/views/aws_ses_form_submission_mailer/submission_email.html.erb index e35ea6966..e813e6563 100644 --- a/app/views/aws_ses_form_submission_mailer/submission_email.html.erb +++ b/app/views/aws_ses_form_submission_mailer/submission_email.html.erb @@ -1,28 +1,27 @@
- This is a completed "<%= @mailer_options.title %>" form. + <%= I18n.t("mailer.submission.title", title: @mailer_options.title) %>
- This form was submitted at <%= @mailer_options.timestamp.strftime("%l:%M%P").strip %> on <%= @mailer_options.timestamp.strftime("%-d %B %Y") %> + <%= I18n.t("mailer.submission.time", time: @mailer_options.timestamp.strftime("%l:%M%P").strip, date: @mailer_options.timestamp.strftime("%-d %B %Y") ) %>
- GOV.UK Forms reference number: <%= @mailer_options.submission_reference %>
+ <%= I18n.t("mailer.submission.reference", submission_reference: @mailer_options.submission_reference) %>
+
+ <%= I18n.t("mailer.submission.check_before_using") %>
--+You cannot reply to this email
-- If you need to contact the person who completed this form, you’ll need to contact them directly. -
-- If you’re experiencing a technical issue with this form, contact the GOV.UK Forms team with details of the issue and the form it relates to. -
-
+
+
|
+
+ |
+
+
|
+ + |
+ |
+ ||
+ |
+ + + + <%= yield %> + + + | ++ |
+
+ |
+
If you need to contact the person who completed this form, you’ll need to contact them directly.
" + contact_forms_team:If you’re experiencing a technical issue with this form, contact the GOV.UK Forms team with details of the issue and the form it relates to.
+ heading: You cannot reply to this email + check_before_using: Check that this data looks safe before you use it + file_attached: "%{filename} (attached to this email)" from: GOV.UK Forms <%{email_address}> + reference: 'GOV.UK Forms reference number: %{submission_reference}' subject: 'Form submission: %{form_title} - reference: %{reference}' + time: This form was submitted at %{time} on %{date} + title: This is a completed “%{title}” form. mode: phase_banner_tag_preview-archived: Archived preview phase_banner_tag_preview-draft: Draft preview diff --git a/spec/mailers/aws_ses_form_submission_mailer_preview.rb b/spec/mailers/aws_ses_form_submission_mailer_preview.rb new file mode 100644 index 000000000..51d8168e8 --- /dev/null +++ b/spec/mailers/aws_ses_form_submission_mailer_preview.rb @@ -0,0 +1,12 @@ +class AwsSesFormSubmissionMailerPreview < ActionMailer::Preview + def submission_email + AwsSesFormSubmissionMailer.submission_email(answer_content: "forms@example.gov.uk
", + submission_email_address: "testing@gov.uk", + mailer_options: FormSubmissionService::MailerOptions.new(title: "Form 1", + preview_mode: false, + timestamp: Time.zone.now, + submission_reference: Faker::Alphanumeric.alphanumeric(number: 8).upcase, + payment_url: nil), + files: {}) + end +end diff --git a/spec/mailers/aws_ses_form_submission_mailer_spec.rb b/spec/mailers/aws_ses_form_submission_mailer_spec.rb index b85fe9d70..16406c653 100644 --- a/spec/mailers/aws_ses_form_submission_mailer_spec.rb +++ b/spec/mailers/aws_ses_form_submission_mailer_spec.rb @@ -26,12 +26,34 @@ expect(mail.subject).to eq("Form submission: #{title} - reference: #{submission_reference}") end + it "has a link to GOV.UK" do + expect(mail.body).to have_link("GOV.UK", href: "https://www.gov.uk") + end + it "includes the answers" do expect(mail.body).to match(answer_content) end + it "includes the form title text" do + expect(mail.body).to have_css("p", text: I18n.t("mailer.submission.title", title:)) + end + + it "includes text about the submission time" do + expect(mail.body).to have_css("p", text: I18n.t("mailer.submission.time", time: submission_timestamp.strftime("%l:%M%P").strip, date: submission_timestamp.strftime("%-d %B %Y"))) + end + it "includes the submission reference" do - expect(mail.body).to match("reference number: #{submission_reference}") + expect(mail.body).to have_css("p", text: I18n.t("mailer.submission.reference", submission_reference:)) + end + + it "includes text about checking the answers" do + expect(mail.body).to have_css("p", text: I18n.t("mailer.submission.check_before_using")) + end + + it "includes the warning about not replying" do + expect(mail.body).to have_css("h2", text: I18n.t("mailer.submission.cannot_reply.heading")) + expect(mail.body).to include(I18n.t("mailer.submission.cannot_reply.contact_form_filler")) + expect(mail.body).to include(I18n.t("mailer.submission.cannot_reply.contact_forms_team")) end describe "submission date/time" do diff --git a/spec/services/aws_ses_submission_service_spec.rb b/spec/services/aws_ses_submission_service_spec.rb index c3a6a12a1..0ca517974 100644 --- a/spec/services/aws_ses_submission_service_spec.rb +++ b/spec/services/aws_ses_submission_service_spec.rb @@ -88,7 +88,7 @@ service.submit expect(AwsSesFormSubmissionMailer).to have_received(:submission_email).with( - { answer_content: "#{question.original_filename}
", + { answer_content: "#{I18n.t('mailer.submission.file_attached', filename: question.original_filename)}
", submission_email_address: submission_email, mailer_options: instance_of(FormSubmissionService::MailerOptions), files: { question.original_filename => file_content } }, @@ -148,7 +148,7 @@ expected_csv_content = "Reference,Submitted at,#{question.question_text}\n#{submission_reference},2022-09-14T08:00:00Z,#{question.original_filename}\n" expect(AwsSesFormSubmissionMailer).to have_received(:submission_email).with( - { answer_content: "#{question.original_filename}
", + { answer_content: "#{I18n.t('mailer.submission.file_attached', filename: question.original_filename)}
", submission_email_address: submission_email, mailer_options: instance_of(FormSubmissionService::MailerOptions), files: {