aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-12-12 17:12:48 -0800
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-12-12 17:12:48 -0800
commit0ef2fdb119a7196a010cd8081f1631f23f5cef95 (patch)
treea290dd9044b6f1298e59b081a5d7c877bbde16f5
parent6edccec1b97af46d2133ce701d7c307d213da9c6 (diff)
downloadrails-0ef2fdb119a7196a010cd8081f1631f23f5cef95.tar.gz
rails-0ef2fdb119a7196a010cd8081f1631f23f5cef95.tar.bz2
rails-0ef2fdb119a7196a010cd8081f1631f23f5cef95.zip
Consistent naming on all factory methods
-rw-r--r--lib/action_mailbox/test_helper.rb10
-rw-r--r--test/unit/inbound_email/message_id_test.rb2
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/action_mailbox/test_helper.rb b/lib/action_mailbox/test_helper.rb
index 23b2bb02ca..680e8b43be 100644
--- a/lib/action_mailbox/test_helper.rb
+++ b/lib/action_mailbox/test_helper.rb
@@ -5,14 +5,15 @@ module ActionMailbox
# 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 file_fixture(fixture_name).read, status: status
+ create_inbound_email_from_source file_fixture(fixture_name).read, status: status
end
def create_inbound_email_from_mail(status: :processing, **mail_options)
- create_inbound_email Mail.new(mail_options).to_s, status: status
+ create_inbound_email_from_source Mail.new(mail_options).to_s, status: status
end
- def create_inbound_email(source, status: :processing)
+ # Create an `InboundEmail` using the raw rfc822 `source` as text.
+ def create_inbound_email_from_source(source, status: :processing)
ActionMailbox::InboundEmail.create_and_extract_message_id! source, status: status
end
@@ -23,5 +24,8 @@ module ActionMailbox
def receive_inbound_email_from_mail(**kwargs)
create_inbound_email_from_mail(**kwargs).tap(&:route)
end
+ def receive_inbound_email_from_source(**kwargs)
+ create_inbound_email_from_source(**kwargs).tap(&:route)
+ end
end
end
diff --git a/test/unit/inbound_email/message_id_test.rb b/test/unit/inbound_email/message_id_test.rb
index c744a5bf99..1cc3de360e 100644
--- a/test/unit/inbound_email/message_id_test.rb
+++ b/test/unit/inbound_email/message_id_test.rb
@@ -7,7 +7,7 @@ class ActionMailbox::InboundEmail::MessageIdTest < ActiveSupport::TestCase
end
test "message id is generated if its missing" do
- inbound_email = create_inbound_email "Date: Fri, 28 Sep 2018 11:08:55 -0700\r\nTo: a@example.com\r\nMime-Version: 1.0\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: 7bit\r\n\r\nHello!"
+ inbound_email = create_inbound_email_from_source "Date: Fri, 28 Sep 2018 11:08:55 -0700\r\nTo: a@example.com\r\nMime-Version: 1.0\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: 7bit\r\n\r\nHello!"
assert_not_nil inbound_email.message_id
end
end