diff options
author | Chris Zetter <zetter@gmail.com> | 2011-11-30 15:04:35 +0000 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-06-18 21:49:43 -0300 |
commit | 8c07696f470cff823ad0b538ca4bea1594742580 (patch) | |
tree | a9775e9453a44be7564de8fd7c38a460c3a6731f /activesupport/test/core_ext | |
parent | 32c65d8da3fd28f8577bc23695846d47cdaac6fb (diff) | |
download | rails-8c07696f470cff823ad0b538ca4bea1594742580.tar.gz rails-8c07696f470cff823ad0b538ca4bea1594742580.tar.bz2 rails-8c07696f470cff823ad0b538ca4bea1594742580.zip |
Fix lookup on HashWithIndifferentAccess for array values.
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 5d422ce5ad..4dc9f57038 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -457,6 +457,13 @@ class HashExtTest < ActiveSupport::TestCase assert_equal '1234', roundtrip.default end + def test_lookup_returns_the_same_object_that_is_stored_in_hash_indifferent_access + hash = HashWithIndifferentAccess.new {|h, k| h[k] = []} + hash[:a] << 1 + + assert_equal [1], hash[:a] + end + def test_indifferent_hash_with_array_of_hashes hash = { "urls" => { "url" => [ { "address" => "1" }, { "address" => "2" } ] }}.with_indifferent_access assert_equal "1", hash[:urls][:url].first[:address] |