diff options
-rw-r--r-- | activesupport/lib/active_support/hash_with_indifferent_access.rb | 2 | ||||
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index 21407327cd..6b7a897cf2 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -112,7 +112,7 @@ module ActiveSupport end def stringify_keys!; self end - def stringify_keys; to_hash end + def stringify_keys; dup end undef :symbolize_keys! def symbolize_keys; to_hash.symbolize_keys end def to_options!; self end diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 1dcde4b665..b2a9731578 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -61,6 +61,7 @@ class HashExtTest < Test::Unit::TestCase end def test_symbolize_keys_for_hash_with_indifferent_access + assert_instance_of Hash, @symbols.with_indifferent_access.symbolize_keys assert_equal @symbols, @symbols.with_indifferent_access.symbolize_keys assert_equal @symbols, @strings.with_indifferent_access.symbolize_keys assert_equal @symbols, @mixed.with_indifferent_access.symbolize_keys @@ -83,12 +84,14 @@ class HashExtTest < Test::Unit::TestCase end def test_stringify_keys_for_hash_with_indifferent_access + assert_instance_of ActiveSupport::HashWithIndifferentAccess, @symbols.with_indifferent_access.stringify_keys assert_equal @strings, @symbols.with_indifferent_access.stringify_keys assert_equal @strings, @strings.with_indifferent_access.stringify_keys assert_equal @strings, @mixed.with_indifferent_access.stringify_keys end def test_stringify_keys_bang_for_hash_with_indifferent_access + assert_instance_of ActiveSupport::HashWithIndifferentAccess, @symbols.with_indifferent_access.dup.stringify_keys! assert_equal @strings, @symbols.with_indifferent_access.dup.stringify_keys! assert_equal @strings, @strings.with_indifferent_access.dup.stringify_keys! assert_equal @strings, @mixed.with_indifferent_access.dup.stringify_keys! |