diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-08 03:44:27 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-08 03:44:27 -0700 |
commit | c2b55c4fbfc427e9ca468fce0392de591c87747a (patch) | |
tree | 40d6cb605293f78791633ce7a5b8a5279fc4ac41 /activesupport/test/core_ext | |
parent | e5a01224195b289748b3996e6deb0587baf625d8 (diff) | |
parent | 099eb2b3fd9526e06c30b9878780f31091e011aa (diff) | |
download | rails-c2b55c4fbfc427e9ca468fce0392de591c87747a.tar.gz rails-c2b55c4fbfc427e9ca468fce0392de591c87747a.tar.bz2 rails-c2b55c4fbfc427e9ca468fce0392de591c87747a.zip |
Merge pull request #454 from dlee/nested_indifferent_access
indifferent access should recurse Hash subclasses
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 3ef080e1cb..4557a10688 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -16,6 +16,12 @@ class HashExtTest < Test::Unit::TestCase class SubclassingHash < Hash end + class NonIndifferentHash < Hash + def nested_under_indifferent_access + self + end + end + def setup @strings = { 'a' => 1, 'b' => 2 } @symbols = { :a => 1, :b => 2 } @@ -109,9 +115,12 @@ class HashExtTest < Test::Unit::TestCase assert_equal @strings, @mixed.with_indifferent_access.dup.stringify_keys! end - def test_hash_subclass - flash = { "foo" => SubclassingHash.new.tap { |h| h["bar"] = "baz" } }.with_indifferent_access - assert_kind_of SubclassingHash, flash["foo"] + def test_nested_under_indifferent_access + foo = { "foo" => SubclassingHash.new.tap { |h| h["bar"] = "baz" } }.with_indifferent_access + assert_kind_of ActiveSupport::HashWithIndifferentAccess, foo["foo"] + + foo = { "foo" => NonIndifferentHash.new.tap { |h| h["bar"] = "baz" } }.with_indifferent_access + assert_kind_of NonIndifferentHash, foo["foo"] end def test_indifferent_assorted |