Skip to content
This repository has been archived by the owner on Aug 17, 2017. It is now read-only.

Commit

Permalink
Merge pull request #242 from astorije/patch-1
Browse files Browse the repository at this point in the history
Ensure arrays of permitted values are supported
  • Loading branch information
rafaelfranca committed Nov 14, 2016
2 parents 8b0e280 + 962cd47 commit 904af29
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/action_controller/parameters.rb
Expand Up @@ -63,7 +63,7 @@ def require(key)
def permit(*filters)
params = self.class.new

filters.each do |filter|
filters.flatten.each do |filter|
case filter
when Symbol, String
permitted_scalar_filter(params, filter)
Expand Down
6 changes: 6 additions & 0 deletions test/parameters_permit_test.rb
Expand Up @@ -104,6 +104,12 @@ def assert_filtered_out(params, key)
assert_equal nil, permitted[:c]
end

test 'permit parameters as an array' do
params = ActionController::Parameters.new(:foo => 'bar')

assert_equal 'bar', params.permit([:foo])[:foo]
end

# --- key to empty array -----------------------------------------------------

test 'key to empty array: empty arrays pass' do
Expand Down

0 comments on commit 904af29

Please sign in to comment.