mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Consistent naming on all factory methods
This commit is contained in:
parent
6edccec1b9
commit
0ef2fdb119
2 changed files with 8 additions and 4 deletions
|
@ -5,14 +5,15 @@ module ActionMailbox
|
||||||
# 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+.
|
# referenced with +fixture_name+ located in +test/fixtures/files/fixture_name+.
|
||||||
def create_inbound_email_from_fixture(fixture_name, status: :processing)
|
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
|
end
|
||||||
|
|
||||||
def create_inbound_email_from_mail(status: :processing, **mail_options)
|
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
|
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
|
ActionMailbox::InboundEmail.create_and_extract_message_id! source, status: status
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,5 +24,8 @@ module ActionMailbox
|
||||||
def receive_inbound_email_from_mail(**kwargs)
|
def receive_inbound_email_from_mail(**kwargs)
|
||||||
create_inbound_email_from_mail(**kwargs).tap(&:route)
|
create_inbound_email_from_mail(**kwargs).tap(&:route)
|
||||||
end
|
end
|
||||||
|
def receive_inbound_email_from_source(**kwargs)
|
||||||
|
create_inbound_email_from_source(**kwargs).tap(&:route)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ class ActionMailbox::InboundEmail::MessageIdTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
test "message id is generated if its missing" do
|
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
|
assert_not_nil inbound_email.message_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue