Skip to content
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

Merged

Conversation

michaelherold
Copy link
Contributor

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 the
power of Mail.new to easily create a variety of emails, from
multi-part emails, to emails with attachments, and beyond.

Other Information

The rdoc-ref to InboundEmail 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.

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@georgeclaghorn georgeclaghorn merged commit ab34ed8 into rails:master Aug 7, 2019
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"
Copy link
Contributor

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.

@michaelherold michaelherold deleted the actionmailbox-multipart-emails branch March 15, 2021 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants