Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Deprecators#disallowed_warnings= #46583

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions activesupport/lib/active_support/deprecation/deprecators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ def disallowed_behavior=(disallowed_behavior)
set_option(:disallowed_behavior, disallowed_behavior)
end

# Sets the disallowed deprecation warnings for all deprecators in this
# collection.
#
# See ActiveSupport::Deprecation::Disallowed#disallowed_warnings=.
def disallowed_warnings=(disallowed_warnings)
set_option(:disallowed_warnings, disallowed_warnings)
end

# Silences all deprecators in this collection for the duration of the
# given block.
#
Expand Down
4 changes: 1 addition & 3 deletions activesupport/lib/active_support/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ class Railtie < Rails::Railtie # :nodoc:
end

if disallowed_warnings = app.config.active_support.disallowed_deprecation_warnings
app.deprecators.each do |deprecator|
deprecator.disallowed_warnings = disallowed_warnings
end
app.deprecators.disallowed_warnings = disallowed_warnings
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions activesupport/test/deprecation/deprecators_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ class DeprecationTest < ActiveSupport::TestCase
@deprecators.each { |deprecator| assert_equal [callback], deprecator.disallowed_behavior }
end

test "#disallowed_warnings= applies to each deprecator" do
@deprecators.disallowed_warnings = :all
@deprecators.each { |deprecator| assert_equal :all, deprecator.disallowed_warnings }
end

test "#silence silences each deprecator" do
@deprecators.each { |deprecator| assert_not_silencing(deprecator) }

Expand Down