diff options
author | Xavier Noria <fxn@hashref.com> | 2018-09-07 23:11:23 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2018-09-07 23:32:54 +0200 |
commit | c03bba4f1f03bad7dc034af555b7f2b329cf76f5 (patch) | |
tree | b069cc53c5ee48238dd8340129911b1ceafda217 /activesupport/test | |
parent | c3e569550ca0a90561fe990f519719ba52402504 (diff) | |
download | rails-c03bba4f1f03bad7dc034af555b7f2b329cf76f5.tar.gz rails-c03bba4f1f03bad7dc034af555b7f2b329cf76f5.tar.bz2 rails-c03bba4f1f03bad7dc034af555b7f2b329cf76f5.zip |
trace autoloads, and document hints for troubleshooting
Closes #32885.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/dependencies_test.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 84cb64a7c2..a486ef5eac 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -1130,3 +1130,52 @@ class DependenciesTest < ActiveSupport::TestCase ActiveSupport::Dependencies.hook! end end + +class DependenciesLogging < ActiveSupport::TestCase + MESSAGE = "message" + + def with_settings(logger, verbose) + original_logger = ActiveSupport::Dependencies.logger + original_verbose = ActiveSupport::Dependencies.verbose + + ActiveSupport::Dependencies.logger = logger + ActiveSupport::Dependencies.verbose = verbose + + yield + ensure + ActiveSupport::Dependencies.logger = original_logger + ActiveSupport::Dependencies.verbose = original_verbose + end + + def fake_logger + Class.new do + def self.debug(message) + message + end + end + end + + test "does not log if the logger is nil and verbose is false" do + with_settings(nil, false) do + assert_nil ActiveSupport::Dependencies.log(MESSAGE) + end + end + + test "does not log if the logger is nil and verbose is true" do + with_settings(nil, true) do + assert_nil ActiveSupport::Dependencies.log(MESSAGE) + end + end + + test "does not log if the logger is set and verbose is false" do + with_settings(fake_logger, false) do + assert_nil ActiveSupport::Dependencies.log(MESSAGE) + end + end + + test "logs if the logger is set and verbose is true" do + with_settings(fake_logger, true) do + assert_equal "autoloading: #{MESSAGE}", ActiveSupport::Dependencies.log(MESSAGE) + end + end +end |