Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore test deliveries properly in ActionMailer.
`ActionMailer::Base.delivery_method` and `ActionMailer::Base.perform_deliveries` have leaked states. "delivery method can be customized per instance" and "delivery method can be customized in subclasses not changing the parent" in delivery_methods_test.rb will fail if test_helper_test.rb (in which TestHelperMailerTest is inherited from ActionMailer::TestCase) runs before it.
- Loading branch information
c4f4123
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.
Hi - could more context be provided on this changeset?
I'm noticing that I'm getting intermittent test failures with this change after upgrading from rails 4.1 b/c the deliveries array isn't cleared out prior to tests running. I had written quite a few tests that asserted that the deliveries array is
empty?
since the guides and other docs say that the actionmailer tests are reset automatically. (Although, combing through the docs now, it doesn't seem extremely clear that it states when they're reset...)It seems surprising to me that more people haven't run into test failures here, since if you turn on randomized test ordering the following sequence is a definite possibility:
ActionMailer::Base.deliveries.empty?
I'm willing to concede that maybe I'm doing something wrong, so - should I not be using
assert ActionMailer::Base.deliveries.empty?
anymore?The thought does occur to me though - it seems more problematic that the example provided in the rails guides could now result in a false positive (test passing when it should have failed), since the deliveries array may not actually be empty.
example from rails guides: