aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschneems <richard.schneeman@gmail.com>2016-01-19 11:53:27 -0600
committerschneems <richard.schneeman@gmail.com>2016-01-19 12:06:29 -0600
commit3f2ac413b7c455ca951944da510683f52cb964da (patch)
treed470e982c9e9b2cb965b658ba8417b9330dfea19
parent66d705b3e7c03f806f7481e0e6a1f157dcf86f83 (diff)
downloadrails-3f2ac413b7c455ca951944da510683f52cb964da.tar.gz
rails-3f2ac413b7c455ca951944da510683f52cb964da.tar.bz2
rails-3f2ac413b7c455ca951944da510683f52cb964da.zip
Add methods to StrongParameters
It's reasonable to expose different value readers.
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb2
-rw-r--r--actionpack/test/controller/required_params_test.rb9
2 files changed, 9 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index 043f69b7bc..70b34c2756 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -109,7 +109,7 @@ module ActionController
cattr_accessor :permit_all_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
# By default, never raise an UnpermittedParameters exception if these
diff --git a/actionpack/test/controller/required_params_test.rb b/actionpack/test/controller/required_params_test.rb
index 129a713564..b6efcd6f9a 100644
--- a/actionpack/test/controller/required_params_test.rb
+++ b/actionpack/test/controller/required_params_test.rb
@@ -66,7 +66,14 @@ class ParametersRequireTest < ActiveSupport::TestCase
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
ActionController::Parameters.new(foo: "bar").merge!({bar: "foo"})
end