Skip to content

Commit

Permalink
Merge pull request #22830 from jcoyne/parameters_include
Browse files Browse the repository at this point in the history
Add AC::Parameters#include?
  • Loading branch information
schneems committed Dec 29, 2015
2 parents 9892758 + ff8a62d commit cc5ae3e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions actionpack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Parameters
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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,10 @@ def dup; @dupped = true; end
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

0 comments on commit cc5ae3e

Please sign in to comment.