From 3f2ac413b7c455ca951944da510683f52cb964da Mon Sep 17 00:00:00 2001 From: schneems Date: Tue, 19 Jan 2016 11:53:27 -0600 Subject: [PATCH] Add methods to StrongParameters It's reasonable to expose different value readers. --- .../lib/action_controller/metal/strong_parameters.rb | 2 +- actionpack/test/controller/required_params_test.rb | 9 ++++++++- 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