2018-09-20 20:16:19 -04:00
|
|
|
require "mail"
|
|
|
|
|
2018-09-28 15:19:43 -04:00
|
|
|
module ActionMailbox
|
2018-09-18 19:07:06 -04:00
|
|
|
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+.
|
2018-09-19 20:08:35 -04:00
|
|
|
def create_inbound_email_from_fixture(fixture_name, status: :processing)
|
2018-10-18 10:23:17 -04:00
|
|
|
create_inbound_email file_fixture(fixture_name).read, status: status
|
2018-10-01 15:42:32 -04:00
|
|
|
end
|
2018-09-19 20:08:35 -04:00
|
|
|
|
2018-09-19 20:13:57 -04:00
|
|
|
def create_inbound_email_from_mail(status: :processing, **mail_options)
|
2018-10-18 10:23:17 -04:00
|
|
|
create_inbound_email Mail.new(mail_options).to_s, status: status
|
2018-09-19 20:08:35 -04:00
|
|
|
end
|
|
|
|
|
2018-10-18 10:23:17 -04:00
|
|
|
def create_inbound_email(source, status: :processing)
|
|
|
|
ActionMailbox::InboundEmail.create_and_extract_message_id! source, status: status
|
2018-09-19 20:08:35 -04:00
|
|
|
end
|
2018-10-01 15:42:32 -04:00
|
|
|
|
2018-10-02 10:06:36 -04:00
|
|
|
def receive_inbound_email_from_fixture(*args)
|
|
|
|
create_inbound_email_from_fixture(*args).tap(&:route)
|
|
|
|
end
|
|
|
|
|
2018-10-01 15:42:32 -04:00
|
|
|
def receive_inbound_email_from_mail(**kwargs)
|
|
|
|
create_inbound_email_from_mail(**kwargs).tap(&:route)
|
|
|
|
end
|
2018-09-18 19:07:06 -04:00
|
|
|
end
|
|
|
|
end
|