diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-11-30 08:27:14 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-11-30 08:27:14 -0800 |
commit | 76c432f5868c8f626a2d38b63b46606e5b1323ff (patch) | |
tree | 38ac54edca8c8f450d272b034e90d39c4eb387c3 /actionpack/test | |
parent | 64c53d7ce40006bdfea59102bdac4cb265d3ecd1 (diff) | |
parent | 83482256efec140b53adde50ba8263af6af7a016 (diff) | |
download | rails-76c432f5868c8f626a2d38b63b46606e5b1323ff.tar.gz rails-76c432f5868c8f626a2d38b63b46606e5b1323ff.tar.bz2 rails-76c432f5868c8f626a2d38b63b46606e5b1323ff.zip |
Merge pull request #8385 from frodsan/strings_love
hash filters should be accessed with symbols or strings
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/parameters/nested_parameters_test.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/actionpack/test/controller/parameters/nested_parameters_test.rb b/actionpack/test/controller/parameters/nested_parameters_test.rb index d287e79cba..6df849c4e2 100644 --- a/actionpack/test/controller/parameters/nested_parameters_test.rb +++ b/actionpack/test/controller/parameters/nested_parameters_test.rb @@ -36,6 +36,31 @@ class NestedParametersTest < ActiveSupport::TestCase assert_nil permitted[:magazine] end + test "permitted nested parameters with a string or a symbol as a key" do + params = ActionController::Parameters.new({ + book: { + 'authors' => [ + { name: 'William Shakespeare', born: '1564-04-26' }, + { name: 'Christopher Marlowe' } + ] + } + }) + + permitted = params.permit book: [ { 'authors' => [ :name ] } ] + + assert_equal 'William Shakespeare', permitted[:book]['authors'][0][:name] + assert_equal 'William Shakespeare', permitted[:book][:authors][0][:name] + assert_equal 'Christopher Marlowe', permitted[:book]['authors'][1][:name] + assert_equal 'Christopher Marlowe', permitted[:book][:authors][1][:name] + + permitted = params.permit book: [ { authors: [ :name ] } ] + + assert_equal 'William Shakespeare', permitted[:book]['authors'][0][:name] + assert_equal 'William Shakespeare', permitted[:book][:authors][0][:name] + assert_equal 'Christopher Marlowe', permitted[:book]['authors'][1][:name] + assert_equal 'Christopher Marlowe', permitted[:book][:authors][1][:name] + end + test "nested arrays with strings" do params = ActionController::Parameters.new({ :book => { |