1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/lib/action_mailroom/test_helper.rb
David Heinemeier Hansson 26bfd1c59c Only deliver pending emails to the mailroom
Makes it easier to test without triggering this behavior.
2018-09-18 17:28:35 -07:00

13 lines
587 B
Ruby

module ActionMailroom
module TestHelper
# 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! \
io: file_fixture(fixture_name).open, filename: fixture_name, content_type: 'message/rfc822'
end
end
end
end