提交 4dcd4069 编写于 作者: R Rick Olson

Fix HashWithIndifferentAccess#to_options! so it doesn't clear the options...

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
上级 1acd54a5
* 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"}}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册