aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-09-25 16:26:53 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-09-25 16:26:53 -0700
commit96b6e7ce669cf412f931e700fafc99d6d7ef031a (patch)
tree9a83e0abace43c641edb41ca8906e08049e24b28 /lib
parent8eb239bd1a1350b151d57a639e589c68aed1f47a (diff)
downloadrails-96b6e7ce669cf412f931e700fafc99d6d7ef031a.tar.gz
rails-96b6e7ce669cf412f931e700fafc99d6d7ef031a.tar.bz2
rails-96b6e7ce669cf412f931e700fafc99d6d7ef031a.zip
Extract and associate message_id with newly created inbound emails
Diffstat (limited to 'lib')
-rw-r--r--lib/action_mailroom/test_helper.rb10
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