The Wire · Showcase
ACTION MAILER TEST ASSERTIONS FIXED FOR NESTED ATTACHMENTS
By RepoJournal · Filed · About Rails
The assert_part and assert_no_part helpers can now see body parts buried inside multipart/alternative containers when attachments are present.
Rails shipped a critical fix [1] to ActionMailer's test assertions that were silently missing nested body parts in messages with both text and HTML bodies alongside attachments. The bug lived in assert_part and assert_no_part [2], which only inspected top-level Mail#parts and couldn't see body parts wrapped in multipart/alternative containers nested below the top-level multipart/mixed part. This broke email testing for the most common real-world scenario: a message with both plain text and HTML versions plus an attachment. The fix [3] changes the assertion logic to traverse the full MIME tree instead of stopping at the surface. If you've written ActionMailer tests since 8.2.0.alpha, your assertions may have been passing falsely - upgrade immediately to catch real failures.
Action items
References
- [1] Fix assert_part/assert_no_part for body parts nested under an attachment rails/rails
- [2] Fix `assert_part` / `assert_no_part` for body parts nested under an attachment ↗ rails/rails
- [3] Merge pull request #57521 from 55728/fix-assert-part-nested-multipart rails/rails
FAQ
- What changed in Rails on June 1, 2026?
- The assert_part and assert_no_part helpers can now see body parts buried inside multipart/alternative containers when attachments are present.
- What should Rails teams do about it?
- Update to latest rails main to pick up the nested multipart assertion fix • Re-run your ActionMailer test suite after upgrading to surface any previously hidden assertion failures
- Which Rails repositories shipped on June 1, 2026?
- rails/rails