Remove deprecated methods in ActionController::Parameters

上级 c396a8c9
* Remove deprecated methods in `ActionController::Parameters`.
*Rafael Mendonça França*
* Remove deprecated support to comparing a `ActionController::Parameters`
with a `Hash`.
......
......@@ -611,28 +611,8 @@ def init_with(coder) # :nodoc:
end
end
# Undefine `to_param` such that it gets caught in the `method_missing`
# deprecation cycle below.
undef_method :to_param
def method_missing(method_sym, *args, &block)
if @parameters.respond_to?(method_sym)
message = <<-DEPRECATE.squish
Method #{method_sym} is deprecated and will be removed in Rails 5.1,
as `ActionController::Parameters` no longer inherits from
hash. Using this deprecated behavior exposes potential security
problems. If you continue to use this method you may be creating
a security vulnerability in your app that can be exploited. Instead,
consider using one of these documented methods which are not
deprecated: http://api.rubyonrails.org/v#{ActionPack.version}/classes/ActionController/Parameters.html
DEPRECATE
ActiveSupport::Deprecation.warn(message)
@parameters.public_send(method_sym, *args, &block)
else
super
end
end
protected
attr_reader :parameters
......
......@@ -72,14 +72,8 @@ class ParametersRequireTest < ActiveSupport::TestCase
assert params.value?("cinco")
end
test "Deprecated methods are deprecated" do
assert_deprecated do
ActionController::Parameters.new(foo: "bar").merge!(bar: "foo")
end
end
test "to_query is not supported" do
assert_deprecated do
assert_raises(NoMethodError) do
ActionController::Parameters.new(foo: "bar").to_param
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册