diff options
author | Steve Klabnik <steve@steveklabnik.com> | 2012-09-14 18:52:15 +0400 |
---|---|---|
committer | Steve Klabnik <steve@steveklabnik.com> | 2012-09-15 06:19:55 +0400 |
commit | ed2fea908a9f8540ac2ea949e3e258ab88769cb1 (patch) | |
tree | e6f036c43be107a8e3631e04ed6bcd0d77d21ad5 /activerecord/test | |
parent | bb732beba7c0c6f54b12eb774bc78790dd955b65 (diff) | |
download | rails-ed2fea908a9f8540ac2ea949e3e258ab88769cb1.tar.gz rails-ed2fea908a9f8540ac2ea949e3e258ab88769cb1.tar.bz2 rails-ed2fea908a9f8540ac2ea949e3e258ab88769cb1.zip |
Deprecate ActiveSupport::Benchmarkable#silence.
Due to its lack of thread safety, we're deprecating this, and it
will be removed in Rails 4.1.
Fixes #4060.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index b9d480d9ce..b25d169038 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1619,26 +1619,32 @@ class BasicsTest < ActiveRecord::TestCase def test_silence_sets_log_level_to_error_in_block original_logger = ActiveRecord::Base.logger - log = StringIO.new - ActiveRecord::Base.logger = ActiveSupport::Logger.new(log) - ActiveRecord::Base.logger.level = Logger::DEBUG - ActiveRecord::Base.silence do - ActiveRecord::Base.logger.warn "warn" - ActiveRecord::Base.logger.error "error" + + assert_deprecated do + log = StringIO.new + ActiveRecord::Base.logger = ActiveSupport::Logger.new(log) + ActiveRecord::Base.logger.level = Logger::DEBUG + ActiveRecord::Base.silence do + ActiveRecord::Base.logger.warn "warn" + ActiveRecord::Base.logger.error "error" + end + assert_equal "error\n", log.string end - assert_equal "error\n", log.string ensure ActiveRecord::Base.logger = original_logger end def test_silence_sets_log_level_back_to_level_before_yield original_logger = ActiveRecord::Base.logger - log = StringIO.new - ActiveRecord::Base.logger = ActiveSupport::Logger.new(log) - ActiveRecord::Base.logger.level = Logger::WARN - ActiveRecord::Base.silence do + + assert_deprecated do + log = StringIO.new + ActiveRecord::Base.logger = ActiveSupport::Logger.new(log) + ActiveRecord::Base.logger.level = Logger::WARN + ActiveRecord::Base.silence do + end + assert_equal Logger::WARN, ActiveRecord::Base.logger.level end - assert_equal Logger::WARN, ActiveRecord::Base.logger.level ensure ActiveRecord::Base.logger = original_logger end |