diff options
author | Xavier Noria <fxn@hashref.com> | 2019-02-15 14:47:16 -0800 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2019-02-15 14:49:44 -0800 |
commit | 3aa3c0684d3bd748be9e85d25616a8a7a1ab7755 (patch) | |
tree | 90db5bb0029ee5e2d2400a6fb7a6019cfd67ada5 /railties | |
parent | a25282ed1e43ea04556c9243b5dc4d62517f43ef (diff) | |
download | rails-3aa3c0684d3bd748be9e85d25616a8a7a1ab7755.tar.gz rails-3aa3c0684d3bd748be9e85d25616a8a7a1ab7755.tar.bz2 rails-3aa3c0684d3bd748be9e85d25616a8a7a1ab7755.zip |
Implement AS::Dependencies.verbose= compatibility for :zeitwerk mode
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/application/zeitwerk_integration_test.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/railties/test/application/zeitwerk_integration_test.rb b/railties/test/application/zeitwerk_integration_test.rb index 16ffbe56bb..c536c2f7f4 100644 --- a/railties/test/application/zeitwerk_integration_test.rb +++ b/railties/test/application/zeitwerk_integration_test.rb @@ -163,4 +163,40 @@ class ZeitwerkIntegrationTest < ActiveSupport::TestCase assert_equal %i(main_autoloader), $zeitwerk_integration_reload_test end + + test "verbose = true sets the debug method of the dependencies logger if present" do + boot + + logger = Logger.new(File::NULL) + ActiveSupport::Dependencies.logger = logger + ActiveSupport::Dependencies.verbose = true + + Rails.autoloaders.each do |autoloader| + assert_equal logger.method(:debug), autoloader.logger + end + end + + test "verbose = true sets the debug method of the Rails logger as fallback" do + boot + + ActiveSupport::Dependencies.verbose = true + + Rails.autoloaders.each do |autoloader| + assert_equal Rails.logger.method(:debug), autoloader.logger + end + end + + test "verbose = false sets loggers to nil" do + boot + + ActiveSupport::Dependencies.verbose = true + Rails.autoloaders.each do |autoloader| + assert autoloader.logger + end + + ActiveSupport::Dependencies.verbose = false + Rails.autoloaders.each do |autoloader| + assert_nil autoloader.logger + end + end end |