diff options
-rw-r--r-- | activesupport/lib/active_support/deprecation.rb | 3 | ||||
-rw-r--r-- | activesupport/test/deprecation_test.rb | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb index f6dc863e41..845fb4d62b 100644 --- a/activesupport/lib/active_support/deprecation.rb +++ b/activesupport/lib/active_support/deprecation.rb @@ -46,6 +46,9 @@ module ActiveSupport @silenced = old_silenced end + attr_writer :silenced + + private def deprecation_message(callstack, message = nil) file, line, method = extract_callstack(callstack) diff --git a/activesupport/test/deprecation_test.rb b/activesupport/test/deprecation_test.rb index cda45c6a9f..12fe5f3bf2 100644 --- a/activesupport/test/deprecation_test.rb +++ b/activesupport/test/deprecation_test.rb @@ -9,7 +9,7 @@ class Deprecatee def old_request; @request end def partially(foo = nil) - ActiveSupport::Deprecation.warn 'calling with foo=nil is out' if foo.nil? + ActiveSupport::Deprecation.warn('calling with foo=nil is out', caller) if foo.nil? end def not() 2 end @@ -82,5 +82,9 @@ class DeprecationTest < Test::Unit::TestCase ActiveSupport::Deprecation.silence do assert_not_deprecated { @dtc.partially } end + + ActiveSupport::Deprecation.silenced = true + assert_not_deprecated { @dtc.partially } + ActiveSupport::Deprecation.silenced = false end end |