Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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#each_value`.

*Lukáš Zapletal*

* Deprecate `ActionDispatch::Http::ParameterFilter` in favor of `ActiveSupport::ParameterFilter`.

*Yoshiyuki Kinjo*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def each_pair(&block)
# 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

Expand Down
8 changes: 6 additions & 2 deletions actionpack/test/controller/parameters/accessors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
bogdanvlviv marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down