aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/lib/active_support/deprecation/behaviors.rb3
-rw-r--r--activesupport/lib/active_support/deprecation/reporting.rb5
-rw-r--r--activesupport/lib/active_support/i18n_railtie.rb1
-rw-r--r--activesupport/test/deprecation_test.rb13
4 files changed, 19 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/deprecation/behaviors.rb b/activesupport/lib/active_support/deprecation/behaviors.rb
index feb1508586..f0842f201d 100644
--- a/activesupport/lib/active_support/deprecation/behaviors.rb
+++ b/activesupport/lib/active_support/deprecation/behaviors.rb
@@ -1,4 +1,5 @@
require "active_support/notifications"
+require "active_support/core_ext/array/wrap"
module ActiveSupport
module Deprecation
@@ -11,7 +12,7 @@ module ActiveSupport
end
def behavior=(behavior)
- @behavior = DEFAULT_BEHAVIORS[behavior] || behavior
+ @behavior = Array.wrap(behavior).map { |b| DEFAULT_BEHAVIORS[b] || b }
end
end
diff --git a/activesupport/lib/active_support/deprecation/reporting.rb b/activesupport/lib/active_support/deprecation/reporting.rb
index 03c445ffbf..49d58cd3a1 100644
--- a/activesupport/lib/active_support/deprecation/reporting.rb
+++ b/activesupport/lib/active_support/deprecation/reporting.rb
@@ -4,8 +4,9 @@ module ActiveSupport
attr_accessor :silenced
def warn(message = nil, callstack = caller)
- if behavior && !silenced
- behavior.call(deprecation_message(callstack, message), callstack)
+ return if silenced
+ deprecation_message(callstack, message).tap do |m|
+ behavior.each { |b| b.call(m, callstack) }
end
end
diff --git a/activesupport/lib/active_support/i18n_railtie.rb b/activesupport/lib/active_support/i18n_railtie.rb
index d82e54f1d4..db09919fd3 100644
--- a/activesupport/lib/active_support/i18n_railtie.rb
+++ b/activesupport/lib/active_support/i18n_railtie.rb
@@ -1,6 +1,7 @@
require "active_support"
require "rails"
require "active_support/file_update_checker"
+require "active_support/core_ext/array/wrap"
module I18n
class Railtie < Rails::Railtie
diff --git a/activesupport/test/deprecation_test.rb b/activesupport/test/deprecation_test.rb
index cf27357b32..44f1aebb37 100644
--- a/activesupport/test/deprecation_test.rb
+++ b/activesupport/test/deprecation_test.rb
@@ -80,6 +80,19 @@ class DeprecationTest < ActiveSupport::TestCase
assert_deprecated(/foo=nil/) { @dtc.partially }
end
+ def test_several_behaviors
+ @a, @b = nil, nil
+
+ ActiveSupport::Deprecation.behavior = [
+ Proc.new { |msg, callstack| @a = msg },
+ Proc.new { |msg, callstack| @b = msg }
+ ]
+
+ @dtc.partially
+ assert_match(/foo=nil/, @a)
+ assert_match(/foo=nil/, @b)
+ end
+
def test_deprecated_instance_variable_proxy
assert_not_deprecated { @dtc.request.size }