Permalink
Browse files

Fix HashWithIndifferentAccess#to_options! so it doesn't clear the opt…

…ions hash. Closes #10419 [ReinH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8332 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 1acd54a commit 4dcd4069f577e2105ea25929be1350fcefb9f71d @technoweenie technoweenie committed Dec 8, 2007
View
@@ -1,3 +1,5 @@
+* Fix HashWithIndifferentAccess#to_options! so it doesn't clear the options hash. Closes #10419 [ReinH]
+
*2.0.1* (December 7th, 2007)
* Added Array#from and Array#to that behaves just from String#from and String#to [DHH]
@@ -63,6 +63,7 @@ def delete(key)
def stringify_keys!; self end
def symbolize_keys!; self end
+ def to_options!; self end
# Convert to a Hash with String keys.
def to_hash
@@ -205,6 +205,14 @@ def test_stringify_and_symbolize_keys_on_indifferent_preserves_hash
assert_equal 1, h[:first]
end
+ def test_to_options_on_indifferent_preserves_hash
+ h = HashWithIndifferentAccess.new
+ h['first'] = 1
+ h.to_options!
+ assert_equal 1, h['first']
+ end
+
+
def test_indifferent_subhashes
h = {'user' => {'id' => 5}}.with_indifferent_access
['user', :user].each {|user| [:id, 'id'].each {|id| assert_equal 5, h[user][id], "h[#{user.inspect}][#{id.inspect}] should be 5"}}

0 comments on commit 4dcd406

Please sign in to comment.