Skip to content

Commit ce9f13c

Browse files
committed
Don't load *_test.rb file from the "fixtures" folder:
- If an application has files named `*_test.rb` in the "fixtures/files" folder, they were picked up to be loaded. In most cases this would result in a LoadError as its likely those files include code that can't be loaded.
1 parent 6e7ef7d commit ce9f13c

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

railties/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* `bin/rails test` will no longer load files named `*_test.rb` if they are located in the `fixtures` folder.
2+
3+
*Edouard Chin*
4+
15
* Ensure logger tags configured with `config.log_tags` are still active in `request.action_dispatch` handlers
26

37
*KJ Tsanaktsidis*

railties/lib/rails/test_unit/runner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def default_test_glob
8787
end
8888

8989
def default_test_exclude_glob
90-
ENV["DEFAULT_TEST_EXCLUDE"] || "test/{system,dummy}/**/*_test.rb"
90+
ENV["DEFAULT_TEST_EXCLUDE"] || "test/{system,dummy,fixtures}/**/*_test.rb"
9191
end
9292

9393
def regexp_filter?(arg)

railties/test/application/test_runner_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,12 @@ class DummyTest < ApplicationSystemTestCase
12231223
assert_match "1 runs, 1 assertions, 0 failures, 0 errors, 0 skips", output
12241224
end
12251225

1226+
def test_run_does_not_load_file_from_the_fixture_folder
1227+
create_test_file "fixtures", "smoke_foo"
1228+
1229+
assert_match "0 runs, 0 assertions, 0 failures, 0 errors, 0 skips", run_test_command("")
1230+
end
1231+
12261232
def test_can_exclude_files_from_being_tested_via_default_rails_command_by_setting_DEFAULT_TEST_EXCLUDE_env_var
12271233
create_test_file "smoke", "smoke_foo"
12281234

0 commit comments

Comments
 (0)