defines Rails.autoloaders.log!

This commit is contained in:
Xavier Noria 2019-08-13 18:14:50 +02:00
parent 841ac6ceb2
commit 5a70f33909
2 changed files with 16 additions and 0 deletions

@ -36,6 +36,10 @@ def logger=(logger)
each { |loader| loader.logger = logger }
end
def log!
each(&:log!)
end
def zeitwerk_enabled?
Rails.configuration.autoloader == :zeitwerk
end

@ -385,4 +385,16 @@ def once_autoloader.reload
assert_nil autoloader.logger
end
end
test "autoloaders.log!" do
app_file "extras/utils.rb", "module Utils; end"
add_to_config %(config.autoload_once_paths << "\#{Rails.root}/extras")
add_to_config "Rails.autoloaders.log!"
out, _err = capture_io { boot }
assert_match %r/^Zeitwerk@rails.main: autoload set for ApplicationRecord/, out
assert_match %r/^Zeitwerk@rails.once: autoload set for Utils/, out
end
end