Raise a better exception when a invalid depreation behavior is set
Fixes #32928.
This commit is contained in:
parent
9f95767979
commit
a213ac360f
|
@ -94,6 +94,10 @@ module ActiveSupport
|
|||
|
||||
private
|
||||
def arity_coerce(behavior)
|
||||
unless behavior.respond_to?(:call)
|
||||
raise ArgumentError, "#{behavior.inspect} is not a valid deprecation behavior."
|
||||
end
|
||||
|
||||
if behavior.arity == 4 || behavior.arity == -1
|
||||
behavior
|
||||
else
|
||||
|
|
|
@ -182,6 +182,14 @@ class DeprecationTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_default_invalid_behavior
|
||||
e = assert_raises(ArgumentError) do
|
||||
ActiveSupport::Deprecation.behavior = :invalid
|
||||
end
|
||||
|
||||
assert_equal ":invalid is not a valid deprecation behavior.", e.message
|
||||
end
|
||||
|
||||
def test_deprecated_instance_variable_proxy
|
||||
assert_not_deprecated { @dtc.request.size }
|
||||
|
||||
|
|
Loading…
Reference in New Issue