mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add methods to StrongParameters
It's reasonable to expose different value readers.
This commit is contained in:
parent
66d705b3e7
commit
3f2ac413b7
2 changed files with 9 additions and 2 deletions
|
@ -109,7 +109,7 @@ module ActionController
|
||||||
cattr_accessor :permit_all_parameters, instance_accessor: false
|
cattr_accessor :permit_all_parameters, instance_accessor: false
|
||||||
cattr_accessor :action_on_unpermitted_parameters, instance_accessor: false
|
cattr_accessor :action_on_unpermitted_parameters, instance_accessor: false
|
||||||
|
|
||||||
delegate :keys, :key?, :has_key?, :empty?, :include?, :inspect,
|
delegate :keys, :key?, :has_key?, :values, :has_value?, :value?, :empty?, :include?, :inspect,
|
||||||
:as_json, to: :@parameters
|
:as_json, to: :@parameters
|
||||||
|
|
||||||
# By default, never raise an UnpermittedParameters exception if these
|
# By default, never raise an UnpermittedParameters exception if these
|
||||||
|
|
|
@ -66,7 +66,14 @@ class ParametersRequireTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "Deprecated method are deprecated" do
|
test "value params" do
|
||||||
|
params = ActionController::Parameters.new(foo: "bar", dog: "cinco")
|
||||||
|
assert_equal ["bar", "cinco"], params.values
|
||||||
|
assert params.has_value?("cinco")
|
||||||
|
assert params.value?("cinco")
|
||||||
|
end
|
||||||
|
|
||||||
|
test "Deprecated methods are deprecated" do
|
||||||
assert_deprecated do
|
assert_deprecated do
|
||||||
ActionController::Parameters.new(foo: "bar").merge!({bar: "foo"})
|
ActionController::Parameters.new(foo: "bar").merge!({bar: "foo"})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue