aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdan <bogdanvlviv@gmail.com>2018-10-15 15:28:15 +0300
committerRyuta Kamizono <kamipo@gmail.com>2018-10-15 21:28:15 +0900
commit6fe45f378ab7bc88fecb99576fa367f83b3255f3 (patch)
treecf74727d60ac74a8d4873d1384aba4ebc46aae8c
parent777cc1da7d3ecca3f669976b47310f362e2bc8a4 (diff)
downloadrails-6fe45f378ab7bc88fecb99576fa367f83b3255f3.tar.gz
rails-6fe45f378ab7bc88fecb99576fa367f83b3255f3.tar.bz2
rails-6fe45f378ab7bc88fecb99576fa367f83b3255f3.zip
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
-rw-r--r--actionpack/CHANGELOG.md4
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb2
-rw-r--r--actionpack/test/controller/parameters/accessors_test.rb8
3 files changed, 11 insertions, 3 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 8205d79dd2..3858c211ea 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,3 +1,7 @@
+* Add `ActionController::Parameters#each_value`.
+
+ *Lukáš Zapletal*
+
* Deprecate `ActionDispatch::Http::ParameterFilter` in favor of `ActiveSupport::ParameterFilter`.
*Yoshiyuki Kinjo*
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index c1272ce667..04922b0715 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -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
diff --git a/actionpack/test/controller/parameters/accessors_test.rb b/actionpack/test/controller/parameters/accessors_test.rb
index 9f1fb3d042..7789e654d5 100644
--- a/actionpack/test/controller/parameters/accessors_test.rb
+++ b/actionpack/test/controller/parameters/accessors_test.rb
@@ -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