diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/action_mailroom/test_helper.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/action_mailroom/test_helper.rb b/lib/action_mailroom/test_helper.rb index 33d32ec899..8ffbe94e6c 100644 --- a/lib/action_mailroom/test_helper.rb +++ b/lib/action_mailroom/test_helper.rb @@ -5,16 +5,18 @@ module ActionMailroom # Create an InboundEmail record using an eml fixture in the format of message/rfc822 # referenced with +fixture_name+ located in +test/fixtures/files/fixture_name+. def create_inbound_email_from_fixture(fixture_name, status: :processing) - create_inbound_email file_fixture(fixture_name).open, filename: fixture_name, status: status + create_inbound_email file_fixture(fixture_name), filename: fixture_name, status: status end def create_inbound_email_from_mail(status: :processing, **mail_options) - create_inbound_email(StringIO.new(Mail.new(mail_options).to_s), status: status) + raw_email = Tempfile.new.tap { |raw_email| raw_email.write Mail.new(mail_options).to_s } + create_inbound_email(raw_email, status: status) end def create_inbound_email(io, filename: 'mail.eml', status: :processing) - ActionMailroom::InboundEmail.create! status: status, raw_email: - ActiveStorage::Blob.create_after_upload!(io: io, filename: filename, content_type: 'message/rfc822') + ActionMailroom::InboundEmail.create_from_raw_email! \ + ActionDispatch::Http::UploadedFile.new(tempfile: io, filename: filename, type: 'message/rfc822'), + status: status end end end |