diff options
author | Xavier Noria <fxn@hashref.com> | 2019-03-15 22:50:04 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2019-03-15 22:59:03 +0100 |
commit | a47c84d584777238a6955e3a08436577c471af0f (patch) | |
tree | 54a0f8606823192c4f9716b6379f396dd9dd6483 /railties | |
parent | 233927965d0bd79752274bbc7394d21efeda54c0 (diff) | |
download | rails-a47c84d584777238a6955e3a08436577c471af0f.tar.gz rails-a47c84d584777238a6955e3a08436577c471af0f.tar.bz2 rails-a47c84d584777238a6955e3a08436577c471af0f.zip |
Engines are reloaded in Zeitwerk mode [closes #35618]
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/application/zeitwerk_integration_test.rb | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/railties/test/application/zeitwerk_integration_test.rb b/railties/test/application/zeitwerk_integration_test.rb index cddbf5a22d..c82b37d07d 100644 --- a/railties/test/application/zeitwerk_integration_test.rb +++ b/railties/test/application/zeitwerk_integration_test.rb @@ -149,22 +149,27 @@ class ZeitwerkIntegrationTest < ActiveSupport::TestCase assert $zeitwerk_integration_test_extras end - test "autoload paths that are below Gem.path go to the once autoloader" do - app_dir "extras" - add_to_config 'config.autoload_paths << "#{Rails.root}/extras"' - - # Mocks Gem.path to include the extras directory. - Gem.singleton_class.prepend( - Module.new do - def path - super + ["#{Rails.root}/extras"] - end - end - ) + test "autoload_paths are set as root dirs of main, and in the same order" do boot - assert_not_includes Rails.autoloaders.main.dirs, "#{app_path}/extras" - assert_includes Rails.autoloaders.once.dirs, "#{app_path}/extras" + existing_autoload_paths = deps.autoload_paths.select { |dir| File.directory?(dir) } + assert_equal existing_autoload_paths, Rails.autoloaders.main.dirs + end + + test "autoload_once_paths go to the once autoloader, and in the same order" do + extras = %w(e1 e2 e3) + extras.each do |extra| + app_dir extra + add_to_config %(config.autoload_once_paths << "\#{Rails.root}/#{extra}") + end + + boot + + extras = extras.map { |extra| "#{app_path}/#{extra}" } + extras.each do |extra| + assert_not_includes Rails.autoloaders.main.dirs, extra + end + assert_equal extras, Rails.autoloaders.once.dirs end test "clear reloads the main autoloader, and does not reload the once one" do |