Skip to content

Commit 90fc21f

Browse files
Merge pull request rails#46583 from jonathanhefner/deprecators-disallowed_warnings
Add `Deprecators#disallowed_warnings=`
2 parents 2d97136 + ff38e2e commit 90fc21f

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

activesupport/lib/active_support/deprecation/deprecators.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ def disallowed_behavior=(disallowed_behavior)
6969
set_option(:disallowed_behavior, disallowed_behavior)
7070
end
7171

72+
# Sets the disallowed deprecation warnings for all deprecators in this
73+
# collection.
74+
#
75+
# See ActiveSupport::Deprecation::Disallowed#disallowed_warnings=.
76+
def disallowed_warnings=(disallowed_warnings)
77+
set_option(:disallowed_warnings, disallowed_warnings)
78+
end
79+
7280
# Silences all deprecators in this collection for the duration of the
7381
# given block.
7482
#

activesupport/lib/active_support/railtie.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ class Railtie < Rails::Railtie # :nodoc:
8888
end
8989

9090
if disallowed_warnings = app.config.active_support.disallowed_deprecation_warnings
91-
app.deprecators.each do |deprecator|
92-
deprecator.disallowed_warnings = disallowed_warnings
93-
end
91+
app.deprecators.disallowed_warnings = disallowed_warnings
9492
end
9593
end
9694
end

activesupport/test/deprecation/deprecators_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ class DeprecationTest < ActiveSupport::TestCase
6363
@deprecators.each { |deprecator| assert_equal [callback], deprecator.disallowed_behavior }
6464
end
6565

66+
test "#disallowed_warnings= applies to each deprecator" do
67+
@deprecators.disallowed_warnings = :all
68+
@deprecators.each { |deprecator| assert_equal :all, deprecator.disallowed_warnings }
69+
end
70+
6671
test "#silence silences each deprecator" do
6772
@deprecators.each { |deprecator| assert_not_silencing(deprecator) }
6873

0 commit comments

Comments
 (0)