Skip to content

Commit

Permalink
Don't load *_test.rb file from the "fixtures" folder:
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
Edouard-chin committed Feb 13, 2024
1 parent 6e7ef7d commit ce9f13c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions railties/CHANGELOG.md
@@ -1,3 +1,7 @@
* `bin/rails test` will no longer load files named `*_test.rb` if they are located in the `fixtures` folder.

*Edouard Chin*

* Ensure logger tags configured with `config.log_tags` are still active in `request.action_dispatch` handlers

*KJ Tsanaktsidis*
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/test_unit/runner.rb
Expand Up @@ -87,7 +87,7 @@ def default_test_glob
end

def default_test_exclude_glob
ENV["DEFAULT_TEST_EXCLUDE"] || "test/{system,dummy}/**/*_test.rb"
ENV["DEFAULT_TEST_EXCLUDE"] || "test/{system,dummy,fixtures}/**/*_test.rb"
end

def regexp_filter?(arg)
Expand Down
6 changes: 6 additions & 0 deletions railties/test/application/test_runner_test.rb
Expand Up @@ -1223,6 +1223,12 @@ class DummyTest < ApplicationSystemTestCase
assert_match "1 runs, 1 assertions, 0 failures, 0 errors, 0 skips", output
end

def test_run_does_not_load_file_from_the_fixture_folder
create_test_file "fixtures", "smoke_foo"

assert_match "0 runs, 0 assertions, 0 failures, 0 errors, 0 skips", run_test_command("")
end

def test_can_exclude_files_from_being_tested_via_default_rails_command_by_setting_DEFAULT_TEST_EXCLUDE_env_var
create_test_file "smoke", "smoke_foo"

Expand Down

0 comments on commit ce9f13c

Please sign in to comment.