aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/configuration_test.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb
index 62d9b1c813..7c613585e0 100644
--- a/railties/test/application/configuration_test.rb
+++ b/railties/test/application/configuration_test.rb
@@ -4,6 +4,7 @@ require "isolation/abstract_unit"
require "rack/test"
require "env_helpers"
require "set"
+require "active_support/core_ext/string/starts_ends_with"
class ::MyMailInterceptor
def self.delivering_email(email); email; end
@@ -1704,6 +1705,33 @@ module ApplicationTests
end
end
+ test "autoload paths are added to $LOAD_PATH by default" do
+ app "development"
+
+ # Action Mailer modifies AS::Dependencies.autoload_paths in-place.
+ autoload_paths = ActiveSupport::Dependencies.autoload_paths
+ autoload_paths_from_app_and_engines = autoload_paths.reject do |path|
+ path.ends_with?("mailers/previews")
+ end
+ assert_equal true, Rails.configuration.add_autoload_paths_to_load_path
+ assert_empty autoload_paths_from_app_and_engines - $LOAD_PATH
+
+ # Precondition, ensure we are testing something next.
+ assert_not_empty Rails.configuration.paths.load_paths
+ 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"
+ app "development"
+
+ assert_empty ActiveSupport::Dependencies.autoload_paths & $LOAD_PATH
+
+ # Precondition, ensure we are testing something next.
+ assert_not_empty Rails.configuration.paths.load_paths
+ assert_empty Rails.configuration.paths.load_paths - $LOAD_PATH
+ end
+
test "autoloading during initialization gets deprecation message and clearing if config.cache_classes is false" do
app_file "lib/c.rb", <<~EOS
class C