Fix `ActionController::Parameters#each_value` and add changelog entry to this method (#34210)

* Fix `ActionController::Parameters#each_value`

`each_value` should yield with "value" of the params instead of "value" as an array.
Related to #33979

* Add changelog entry about `ActionController::Parameters#each_value`.

Follow up #33979
This commit is contained in:
Bogdan 2018-10-15 15:28:15 +03:00 committed by Ryuta Kamizono
parent 777cc1da7d
commit 6fe45f378a
3 changed files with 11 additions and 3 deletions

View File

@ -1,3 +1,7 @@
* Add `ActionController::Parameters#each_value`.
*Lukáš Zapletal*
* Deprecate `ActionDispatch::Http::ParameterFilter` in favor of `ActiveSupport::ParameterFilter`.
*Yoshiyuki Kinjo*

View File

@ -352,7 +352,7 @@ module ActionController
# the same way as <tt>Hash#each_value</tt>.
def each_value(&block)
@parameters.each_pair do |key, value|
yield [convert_hashes_to_parameters(key, value)]
yield convert_hashes_to_parameters(key, value)
end
end

View File

@ -77,11 +77,15 @@ class ParametersAccessorsTest < ActiveSupport::TestCase
test "each_value carries permitted status" do
@params.permit!
@params["person"].each_value { |value| assert(value.permitted?) if value == 32 }
@params.each_value do |value|
assert_predicate(value, :permitted?)
end
end
test "each_value carries unpermitted status" do
@params["person"].each_value { |value| assert_not(value.permitted?) if value == 32 }
@params.each_value do |value|
assert_not_predicate(value, :permitted?)
end
end
test "each_key converts to hash for permitted" do