diff --git a/test/fixtures/receipt_mailer/transfer_receipt_email b/test/fixtures/receipt_mailer/transfer_receipt_email deleted file mode 100644 index 5d84a766..00000000 --- a/test/fixtures/receipt_mailer/transfer_receipt_email +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - -

Hello Admin,

- -

Below is a record of the files you submitted on Apr 7, 2021 at 8:05 AM.

- -

A couple reminders:

- - - -

Files transferred:

- -
    -
  1. a_pdf.pdf
  2. -
- -

Let us know if you have any questions.

- -

Thanks,

-

The Thesis team at the MIT Libraries

- - - diff --git a/test/mailers/receipt_mailer_test.rb b/test/mailers/receipt_mailer_test.rb index e31aec70..04b38763 100644 --- a/test/mailers/receipt_mailer_test.rb +++ b/test/mailers/receipt_mailer_test.rb @@ -23,10 +23,9 @@ class ReceiptMailerTest < ActionMailer::TestCase test 'sends confirmation emails for transfer records' do ClimateControl.modify DISABLE_ALL_EMAIL: 'false' do transfer = transfers(:valid) - transfer.created_at = Time.new(2021, 4, 7, 8, 05, 0) f = Rails.root.join('test','fixtures','files','a_pdf.pdf') transfer.files.attach(io: File.open(f), filename: 'a_pdf.pdf') - user = users(:admin) + user = users(:transfer_submitter) email = ReceiptMailer.transfer_receipt_email(transfer, user) # Send the email, then test that it got queued @@ -36,9 +35,18 @@ class ReceiptMailerTest < ActionMailer::TestCase # Test the body of the sent email contains what we expect it to assert_equal ['test@example.com'], email.from - assert_equal ['admin@example.com'], email.to + assert_equal ['transfer@example.com'], email.to assert_equal 'Thesis files transferred', email.subject - assert_equal read_fixture('transfer_receipt_email').join, email.body.to_s + # Please note: we are not attempting to assert_equal on the entire + # message because this email currently includes a reference to the + # transfer.created_at value, which puts us into dealing with timezones. + # I have lost more hours testing timezones than I care to calculate. + # Instead, we test for the presence of values we actually care about in + # the email body (filenames, and a greeting). + # Test that we are greeting the submitter by name + assert_match 'Hello Terry,', email.body.to_s + # Test that the filename we transferred appears in the body of the email + assert_match 'a_pdf.pdf', email.body.to_s end end