diff options
author | Dominic Cleal <dominic@cleal.org> | 2017-01-24 10:55:43 +0000 |
---|---|---|
committer | Dominic Cleal <dominic@cleal.org> | 2017-12-06 14:50:35 +0000 |
commit | d7a121a0d624dd8180556521f0611d4c8e2c648f (patch) | |
tree | 4743d2db9cf6ee807b1e8e7560a369d0002d6fc4 /actionpack/test/controller/parameters | |
parent | ce37e1643a62436a7c0ce059def4c5d9c72f7367 (diff) | |
download | rails-d7a121a0d624dd8180556521f0611d4c8e2c648f.tar.gz rails-d7a121a0d624dd8180556521f0611d4c8e2c648f.tar.bz2 rails-d7a121a0d624dd8180556521f0611d4c8e2c648f.zip |
Yield array from AC::Parameters#each for block with one arg
Matches Hash#each behaviour as used in Rails 4.
Diffstat (limited to 'actionpack/test/controller/parameters')
-rw-r--r-- | actionpack/test/controller/parameters/accessors_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/actionpack/test/controller/parameters/accessors_test.rb b/actionpack/test/controller/parameters/accessors_test.rb index 43cabae7d2..154430d4b0 100644 --- a/actionpack/test/controller/parameters/accessors_test.rb +++ b/actionpack/test/controller/parameters/accessors_test.rb @@ -51,6 +51,14 @@ class ParametersAccessorsTest < ActiveSupport::TestCase @params.each { |key, value| assert_not(value.permitted?) if key == "person" } end + test "each returns key,value array for block with arity 1" do + @params.each do |arg| + assert_kind_of Array, arg + assert_equal "person", arg[0] + assert_kind_of ActionController::Parameters, arg[1] + end + end + test "each_pair carries permitted status" do @params.permit! @params.each_pair { |key, value| assert(value.permitted?) if key == "person" } @@ -60,6 +68,14 @@ class ParametersAccessorsTest < ActiveSupport::TestCase @params.each_pair { |key, value| assert_not(value.permitted?) if key == "person" } end + test "each_pair returns key,value array for block with arity 1" do + @params.each_pair do |arg| + assert_kind_of Array, arg + assert_equal "person", arg[0] + assert_kind_of ActionController::Parameters, arg[1] + end + end + test "empty? returns true when params contains no key/value pairs" do params = ActionController::Parameters.new assert params.empty? |