diff options
author | Kevin Sjöberg <kev.sjoberg@gmail.com> | 2018-06-19 21:38:26 +0200 |
---|---|---|
committer | Rafael França <rafaelmfranca@gmail.com> | 2018-06-19 15:38:26 -0400 |
commit | 716f2e09c23e48716460027b78d2133bce0cdf3e (patch) | |
tree | 5014ce1090846558c047d5b4adccb6d80d733e9b /actionpack/test | |
parent | 897946f2141662a072a8917946737218df82e204 (diff) | |
download | rails-716f2e09c23e48716460027b78d2133bce0cdf3e.tar.gz rails-716f2e09c23e48716460027b78d2133bce0cdf3e.tar.bz2 rails-716f2e09c23e48716460027b78d2133bce0cdf3e.zip |
Convert hashes into parameters (#33076)
* Convert hashes into parameters
Ensure `ActionController::Parameters#transform_values` and
`ActionController::Parameters#transform_values!` converts hashes into
parameters.
* fixup! Convert hashes into parameters
[Rafael Mendonça França + Kevin Sjöberg]
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/parameters/accessors_test.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/actionpack/test/controller/parameters/accessors_test.rb b/actionpack/test/controller/parameters/accessors_test.rb index 674b2c6266..68c7f2d9ea 100644 --- a/actionpack/test/controller/parameters/accessors_test.rb +++ b/actionpack/test/controller/parameters/accessors_test.rb @@ -190,6 +190,27 @@ class ParametersAccessorsTest < ActiveSupport::TestCase assert_not_predicate @params.transform_values { |v| v }, :permitted? end + test "transform_values converts hashes to parameters" do + @params.transform_values do |value| + assert_kind_of ActionController::Parameters, value + value + end + end + + test "transform_values without block yieds an enumerator" do + assert_kind_of Enumerator, @params.transform_values + end + + test "transform_values! converts hashes to parameters" do + @params.transform_values! do |value| + assert_kind_of ActionController::Parameters, value + end + end + + test "transform_values! without block yields an enumerator" do + assert_kind_of Enumerator, @params.transform_values! + end + test "value? returns true if the given value is present in the params" do params = ActionController::Parameters.new(city: "Chicago", state: "Illinois") assert params.value?("Chicago") |