Skip to content
Browse files

Fix OrderedHash#to_hash to return self instead of a new hash with sel…

…f as default value
  • Loading branch information...
1 parent a242abb commit cb534524389bb4f407fc268a0bb7a7cffb6785a9 @jeremy jeremy committed Mar 3, 2009
Showing with 6 additions and 2 deletions.
  1. +1 −1 activesupport/lib/active_support/ordered_hash.rb
  2. +5 −1 activesupport/test/ordered_hash_test.rb
View
2 activesupport/lib/active_support/ordered_hash.rb
@@ -54,7 +54,7 @@ def values
end
def to_hash
- Hash.new(self)
+ self
end
def each_key
View
6 activesupport/test/ordered_hash_test.rb
@@ -45,6 +45,10 @@ def test_delete
assert_nil @ordered_hash.delete(bad_key)
end
+ def test_to_hash
+ assert_same @ordered_hash, @ordered_hash.to_hash
+ end
+
def test_has_key
assert_equal true, @ordered_hash.has_key?('blue')
assert_equal true, @ordered_hash.key?('blue')
@@ -148,4 +152,4 @@ def test_keys
@ordered_hash.keys.pop
assert_equal original, @ordered_hash.keys
end
-end
+end

1 comment on commit cb53452

@methodmissing

Jeremy,

Noticed some recursion with OrderedHash#inspect …

Please sign in to comment.
Something went wrong with that request. Please try again.