New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow easily testing multi-part emails in ActionMailbox #36856
Allow easily testing multi-part emails in ActionMailbox #36856
Conversation
When you wanted to test a multi-part email -- for example, an email that has both a plaintext part and an HTML part -- there wasn't a way to easily build one without a pre-made fixture. By allowing you to pass a block to the `create_inbound_email_from_mail` method, we unlock the power of `Mail.new` to easily create a variety of emails, from multi-part emails, to emails with attachments, and beyond.
Like with its `create_` counterpart, it is useful to be able to immediately process a flexibly-created email with multiple parts, attachments, and the like. Allowing the use of the block constructor makes this method more flexible and easier to use.
\r | ||
<h1>Hello, world</h1> | ||
HTML | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case is for ActionMailbox::InboundEmail
. How about adding ActionMailbox::TestHelperTest
in test/unit/test_helper_test.rb
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I put it here since there wasn't an explicit test for TestHelper
, but that makes a lot of sense to me.
test "multi-part mail can be built in tests using a block" do | ||
inbound_email = create_inbound_email_from_mail do | ||
to "test@example.com" | ||
from "hello@example.com" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is missing the assertion for subject
. I think we should add it.
Summary
When you wanted to test a multi-part email -- for example, an email that
has both a plaintext part and an HTML part -- there wasn't a way to
easily build one without a pre-made fixture. By allowing you to pass a
block to the
create_inbound_email_from_mail
method, we unlock thepower of
Mail.new
to easily create a variety of emails, frommulti-part emails, to emails with attachments, and beyond.
Other Information
The
rdoc-ref
toInboundEmail
wasn't linking up when I was testing it.I was running
bundle exec rake rdoc
to generate the documentation,which I think is correct, but noticed that it was dropping the link.