From c859cd256fda470ad284b21b8595d75b78eebc9f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 12 Dec 2018 17:13:35 -0800 Subject: Explain all test helpers --- lib/action_mailbox/test_helper.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3