From f8e67bcfc08d45cfaebbb7057dd6d974de856b12 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Tue, 11 Jan 2022 14:24:10 +0100 Subject: [PATCH] Fix the tests broken by the new add_autoload_paths_to_load_path I didn't pay attention to CI at all -_-. --- railties/test/application/configuration_test.rb | 10 +++------- .../test/application/initializers/load_path_test.rb | 4 ++-- railties/test/application/paths_test.rb | 6 +++--- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 3564008a0f..a09c18d602 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -1822,7 +1822,8 @@ module ApplicationTests end end - test "autoload paths are added to $LOAD_PATH by default" do + test "autoload paths are not added to $LOAD_PATH if opted-in" do + add_to_config "config.add_autoload_paths_to_load_path = true" app "development" # Action Mailer modifies AS::Dependencies.autoload_paths in-place. @@ -1838,8 +1839,7 @@ module ApplicationTests assert_empty Rails.configuration.paths.load_paths - $LOAD_PATH end - test "autoload paths are not added to $LOAD_PATH if opted-out" do - add_to_config "config.add_autoload_paths_to_load_path = false" + test "autoload paths are not added to $LOAD_PATH by default" do app "development" assert_empty ActiveSupport::Dependencies.autoload_paths & $LOAD_PATH @@ -1868,10 +1868,6 @@ module ApplicationTests assert_includes config.autoload_once_paths, "#{app_path}/custom_autoload_once_path" assert_includes config.eager_load_paths, "#{app_path}/custom_eager_load_path" end - - assert_includes $LOAD_PATH, "#{app_path}/custom_autoload_path" - assert_includes $LOAD_PATH, "#{app_path}/custom_autoload_once_path" - assert_includes $LOAD_PATH, "#{app_path}/custom_eager_load_path" end test "load_database_yaml returns blank hash if configuration file is blank" do diff --git a/railties/test/application/initializers/load_path_test.rb b/railties/test/application/initializers/load_path_test.rb index 78cd4776d6..f59490aec7 100644 --- a/railties/test/application/initializers/load_path_test.rb +++ b/railties/test/application/initializers/load_path_test.rb @@ -15,13 +15,13 @@ module ApplicationTests teardown_app end - test "initializing an application adds the application paths to the load path" do + test "initializing an application doesn't add the application paths to the load path" do add_to_config <<-RUBY config.root = "#{app_path}" RUBY require "#{app_path}/config/environment" - assert_includes $:, "#{app_path}/app/models" + assert_not_includes $:, "#{app_path}/app/models" end test "initializing an application allows to load code on lib path inside application class definition" do diff --git a/railties/test/application/paths_test.rb b/railties/test/application/paths_test.rb index 3f1b188c81..e7c2a3db5d 100644 --- a/railties/test/application/paths_test.rb +++ b/railties/test/application/paths_test.rb @@ -69,12 +69,12 @@ module ApplicationTests end test "load path includes each of the paths in config.paths as long as the directories exist" do - assert_in_load_path "app", "controllers" - assert_in_load_path "app", "models" - assert_in_load_path "app", "helpers" assert_in_load_path "lib" assert_in_load_path "vendor" + assert_not_in_load_path "app", "controllers" + assert_not_in_load_path "app", "models" + assert_not_in_load_path "app", "helpers" assert_not_in_load_path "app", "views" assert_not_in_load_path "config" assert_not_in_load_path "config", "locales"