|
1 | 1 | require "rails_helper" |
2 | 2 |
|
3 | 3 | describe AwsSesFormSubmissionMailer, type: :mailer do |
4 | | - subject(:mail) { described_class.submission_email(answer_content_html:, answer_content_plain_text:, submission:, files:, csv_filename:) } |
| 4 | + subject(:mail) { described_class.submission_email(answer_content_html:, answer_content_plain_text:, submission:, files:, csv_filename:, json_filename:) } |
5 | 5 |
|
6 | 6 | let(:submission) do |
7 | 7 | build(:submission, form_document: form_document, created_at: submission_timestamp, |
|
17 | 17 | let(:submission_reference) { Faker::Alphanumeric.alphanumeric(number: 8).upcase } |
18 | 18 | let(:payment_url) { nil } |
19 | 19 | let(:csv_filename) { nil } |
| 20 | + let(:json_filename) { nil } |
20 | 21 | let(:submission_timestamp) { Time.utc(2022, 12, 14, 13, 0o0, 0o0) } |
21 | 22 |
|
22 | 23 | context "when form filler submits a completed form" do |
|
256 | 257 | expect(part.body).not_to have_text(I18n.t("mailer.submission.csv_file", filename: csv_filename)) |
257 | 258 | end |
258 | 259 | end |
| 260 | + |
| 261 | + context "when the json file of answers is attached" do |
| 262 | + let(:json_filename) { "my_answers.json" } |
| 263 | + |
| 264 | + describe "the html part" do |
| 265 | + let(:part) { mail.html_part } |
| 266 | + |
| 267 | + it "includes text about the JSON filename" do |
| 268 | + expect(part.body).to have_css("p", text: I18n.t("mailer.submission.json_file", filename: json_filename)) |
| 269 | + end |
| 270 | + end |
| 271 | + |
| 272 | + describe "the plaintext part" do |
| 273 | + let(:part) { mail.text_part } |
| 274 | + |
| 275 | + it "includes text about the JSON filename" do |
| 276 | + expect(part.body).to have_text(I18n.t("mailer.submission.json_file", filename: json_filename)) |
| 277 | + end |
| 278 | + end |
| 279 | + end |
259 | 280 | end |
260 | 281 | end |
261 | 282 |
|
|
0 commit comments