aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-09-19 16:21:53 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-09-19 16:21:53 -0700
commit67ba89a8c7b4c28cb38184ac15bc3c6aa8a20cbf (patch)
tree1caf7fe7f6dc06d085610d19dcaed9f79c261790 /lib
parentd481dd565d92dc3ff9f2868b6b6126384f8a8145 (diff)
downloadrails-67ba89a8c7b4c28cb38184ac15bc3c6aa8a20cbf.tar.gz
rails-67ba89a8c7b4c28cb38184ac15bc3c6aa8a20cbf.tar.bz2
rails-67ba89a8c7b4c28cb38184ac15bc3c6aa8a20cbf.zip
Ensure raw email is created first
Otherwise jobs hanging off the InboundEmail won't be able to access the Active Storage data (as it won't have been uploaded yet).
Diffstat (limited to 'lib')
-rw-r--r--lib/action_mailroom/test_helper.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/action_mailroom/test_helper.rb b/lib/action_mailroom/test_helper.rb
index 94321ecad3..06a38f75b6 100644
--- a/lib/action_mailroom/test_helper.rb
+++ b/lib/action_mailroom/test_helper.rb
@@ -3,11 +3,10 @@ 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(fixture_name, status: :processing)
- ActionMailroom::InboundEmail.create!(status: status).tap do |inbound_email|
- inbound_email.raw_email.attach \
- ActiveStorage::Blob.create_after_upload! \
+ raw_email = ActiveStorage::Blob.create_after_upload! \
io: file_fixture(fixture_name).open, filename: fixture_name, content_type: 'message/rfc822'
- end
- end
+
+ ActionMailroom::InboundEmail.create!(status: status, raw_email: raw_email)
+ end
end
end