aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Coyne <jcoyne@justincoyne.com>2015-12-29 10:10:04 -0600
committerJustin Coyne <jcoyne@justincoyne.com>2015-12-29 10:11:26 -0600
commitff8a62d1d071500756cd61fcd30fc2984e0fbc26 (patch)
treed35a741413d8ef0c75198b9629ac1dbaf2437088
parent929c61573e289e432a4e571ae157248745ae2eae (diff)
downloadrails-ff8a62d1d071500756cd61fcd30fc2984e0fbc26.tar.gz
rails-ff8a62d1d071500756cd61fcd30fc2984e0fbc26.tar.bz2
rails-ff8a62d1d071500756cd61fcd30fc2984e0fbc26.zip
Add AC::Parameters#include?
Fixes #22818
-rw-r--r--actionpack/CHANGELOG.md4
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb2
-rw-r--r--actionpack/test/controller/parameters/parameters_permit_test.rb6
3 files changed, 11 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index dec8e0cadf..93f75ba635 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,3 +1,7 @@
+* Add `ActionController::Parameters#include?`
+
+ *Justin Coyne*
+
## Rails 5.0.0.beta1 (December 18, 2015) ##
* Deprecate `redirect_to :back` in favor of `redirect_back`, which accepts a
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index 957aa746c0..7e2745c75a 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?, :inspect, to: :@parameters
+ delegate :keys, :key?, :has_key?, :empty?, :include?, :inspect, to: :@parameters
# By default, never raise an UnpermittedParameters exception if these
# params are present. The default includes both 'controller' and 'action'
diff --git a/actionpack/test/controller/parameters/parameters_permit_test.rb b/actionpack/test/controller/parameters/parameters_permit_test.rb
index f23aa599c1..fb72fca789 100644
--- a/actionpack/test/controller/parameters/parameters_permit_test.rb
+++ b/actionpack/test/controller/parameters/parameters_permit_test.rb
@@ -325,4 +325,10 @@ class ParametersPermitTest < ActiveSupport::TestCase
assert_equal({ 'companies' => [ company, :acme ] }, params.to_unsafe_h)
assert_not company.dupped
end
+
+ test "included? returns true when the key is present" do
+ assert @params.include? :person
+ assert @params.include? 'person'
+ assert_not @params.include? :gorilla
+ end
end