Fix HashWithIndifferentAccess#to_options! so it doesn't clear the options hash. Closes #10419 [ReinH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8332 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Rick Olson 2007-12-08 00:12:52 +00:00
parent 1acd54a5b4
commit 4dcd4069f5
3 changed files with 11 additions and 0 deletions

@ -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"}}