1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Explain all test helpers

This commit is contained in:
David Heinemeier Hansson 2018-12-12 17:13:35 -08:00
parent 3e7ce697bf
commit c859cd256f

View file

@ -2,12 +2,15 @@ require "mail"
module ActionMailbox
module TestHelper
# Create an InboundEmail record using an eml fixture in the format of message/rfc822
# 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_from_source file_fixture(fixture_name).read, status: status
end
# Create an `InboundEmail` by specifying it using `Mail.new` options. Example:
#
# create_inbound_email_from_mail(from: "david@loudthinking.com", subject: "Hello!")
def create_inbound_email_from_mail(status: :processing, **mail_options)
create_inbound_email_from_source Mail.new(mail_options).to_s, status: status
end
@ -17,13 +20,21 @@ module ActionMailbox
ActionMailbox::InboundEmail.create_and_extract_message_id! source, status: status
end
# Create an `InboundEmail` from fixture using the same arguments as `create_inbound_email_from_fixture`
# and immediately route it to processing.
def receive_inbound_email_from_fixture(*args)
create_inbound_email_from_fixture(*args).tap(&:route)
end
# Create an `InboundEmail` from fixture using the same arguments as `create_inbound_email_from_mail`
# and immediately route it to processing.
def receive_inbound_email_from_mail(**kwargs)
create_inbound_email_from_mail(**kwargs).tap(&:route)
end
# Create an `InboundEmail` from fixture using the same arguments as `create_inbound_email_from_source`
# and immediately route it to processing.
def receive_inbound_email_from_source(**kwargs)
create_inbound_email_from_source(**kwargs).tap(&:route)
end