assert_changes works on including ActiveSupport::Assertions class #42870
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Hi beloved rails team. This is my attempt to fix #42869.
On the two possible approaches that I proposed on the issue, moving the alias to the Assertions module doesn't work because the alias assignment happens on loading the class, which fails because the method that the alias will redirect to doesn't exist yet. So I just renamed the method to use the original one from rails that
assert_not_equal is an alias for refute_equal that is defined only on the class ActiveSupport::TestCase. This commit ensures ActiveSupport::Testing::Assertions#assert_changes doesn't depends on ActiveSupport::TestCase to work.
Other Information
As I said on the issue I created, this used to work on 6.0.4 and on previously rails versions, stopped worked after we upgraded to rails 6.1
The code that I'm running started to fail on rails 6.1 is something like