mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
parent
c989a18a74
commit
1d375e59f1
2 changed files with 10 additions and 1 deletions
|
@ -421,7 +421,7 @@ module ActionController
|
|||
|
||||
# Slicing filters out non-declared keys.
|
||||
slice(*filter.keys).each do |key, value|
|
||||
return unless value
|
||||
next unless value
|
||||
|
||||
if filter[key] == EMPTY_ARRAY
|
||||
# Declaration { comment_ids: [] }.
|
||||
|
|
|
@ -107,6 +107,15 @@ class ParametersPermitTest < ActiveSupport::TestCase
|
|||
assert_equal [], permitted[:id]
|
||||
end
|
||||
|
||||
test 'do not break params filtering on nil values' do
|
||||
params = ActionController::Parameters.new(a: 1, b: [1, 2, 3], c: nil)
|
||||
|
||||
permitted = params.permit(:a, c: [], b: [])
|
||||
assert_equal 1, permitted[:a]
|
||||
assert_equal [1, 2, 3], permitted[:b]
|
||||
assert_equal nil, permitted[:c]
|
||||
end
|
||||
|
||||
test 'key to empty array: arrays of permitted scalars pass' do
|
||||
[['foo'], [1], ['foo', 'bar'], [1, 2, 3]].each do |array|
|
||||
params = ActionController::Parameters.new(id: array)
|
||||
|
|
Loading…
Reference in a new issue