You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix multiple test leaks and inconsistencies in railties tests
`Rails` is a constant (a module), and `Rails.app_class` and
`Rails.application` are memoized (see
[here](https://github.com/rails/rails/blob/3872bc0e54d32e8bf3a6299b0bfe173d94b072fc/railties/lib/rails.rb#L35-L41)).
`Rails.application` will get memoized the first time it's called, and
then leak to following tests in the run.
This can cause problems when using setups such as `build_app`, which is
supposed to generate a new application from template, which
`Rails.application` would then point at.
By ensuring that `Rails.app_class` and `Rails.application` have been
nullified at the top of `build_app` and restoring at teardown, we can
prevent some leaks.
To reproduce, run `bin/test --seed 65206 -v`.
Without this fix, you'll notice the first failing test is
`Rails::Command::RoutesTest#test_rails_routes_with_namespaced_controller_search_key`.
With the fix, you can confirm that test and many others will pass.
Depending on the order tests run, `Rails.application might get memoized
Also fixes some failures cause by an inconsistent `Rails.root` depending
on whether tests are ran with `bin/test` or through `rake.
Co-Authored-By: Jean Boussier <[email protected]>
expect=%r{\AE\n\nError:\nTestUnitReporterTest::ExampleTest#woot:\nArgumentError: wups\n some_test.rb:4\n\nbin/rails test .*test/test_unit/reporter_test\.rb:\d+\n\n\z}
expect=%r{\ATestUnitReporterTest::ExampleTest#woot = 10\.00 s = S\n\n\nSkipped:\nTestUnitReporterTest::ExampleTest#woot \[[^\]]+\]:\nskipchurches, misstemples\n\nbin/rails test test/test_unit/reporter_test\.rb:\d+\n\n\z}
84
+
expect=%r{\ATestUnitReporterTest::ExampleTest#woot = 10\.00 s = S\n\n\nSkipped:\nTestUnitReporterTest::ExampleTest#woot \[[^\]]+\]:\nskipchurches, misstemples\n\n#{test_run_command_regex} test/test_unit/reporter_test\.rb:\d+\n\n\z}
expected=%r{\e\[31mF\e\[0m\n\n\e\[31mFailure:\nTestUnitReporterTest::ExampleTest#woot \[test/test_unit/reporter_test.rb:\d+\]:\nboo\n\e\[0m\n\nbin/rails test .*test/test_unit/reporter_test.rb:\d+\n\n}
0 commit comments