Permalink
Browse files

Change HWIA#stringify_keys to return a HWIA not a Hash

  • Loading branch information...
1 parent d692e6b commit c976784381d694df8090ad8a16c2648e93a2bd12 @jeremy jeremy committed Apr 22, 2010
View
2 activesupport/lib/active_support/hash_with_indifferent_access.rb
@@ -112,7 +112,7 @@ def delete(key)
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
View
3 activesupport/test/core_ext/hash_ext_test.rb
@@ -61,6 +61,7 @@ def test_stringify_keys!
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 @@ def test_symbolize_keys_preserves_fixnum_keys_for_hash_with_indifferent_access
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!

0 comments on commit c976784

Please sign in to comment.