aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-12-12 17:13:35 -0800
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-12-12 17:13:35 -0800
commitc859cd256fda470ad284b21b8595d75b78eebc9f (patch)
tree417c7faa6f6678e82d03d789782fa2376f010414 /lib
parent3e7ce697bfae0beff3d2141e978e2dba1ceb3a42 (diff)
downloadrails-c859cd256fda470ad284b21b8595d75b78eebc9f.tar.gz
rails-c859cd256fda470ad284b21b8595d75b78eebc9f.tar.bz2
rails-c859cd256fda470ad284b21b8595d75b78eebc9f.zip
Explain all test helpers
Diffstat (limited to 'lib')
-rw-r--r--lib/action_mailbox/test_helper.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/action_mailbox/test_helper.rb b/lib/action_mailbox/test_helper.rb
index 680e8b43be..4e4552629a 100644
--- a/lib/action_mailbox/test_helper.rb
+++ b/lib/action_mailbox/test_helper.rb
@@ -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