提交 185c3dbc 编写于 作者: W Will Bryant

assigns(:foo) should not convert @foo's keys to strings if it happens to be a hash

上级 2f689d46
......@@ -5,7 +5,8 @@
module ActionDispatch
module TestProcess
def assigns(key = nil)
assigns = @controller.view_assigns.with_indifferent_access
assigns = {}.with_indifferent_access
@controller.view_assigns.each {|k, v| assigns.regular_writer(k, v)}
key.nil? ? assigns : assigns[key]
end
......
......@@ -119,6 +119,7 @@ def delete_cookie
def test_assigns
@foo = "foo"
@foo_hash = {:foo => :bar}
render :nothing => true
end
......@@ -292,6 +293,10 @@ def test_assigns
assert_equal "foo", assigns("foo")
assert_equal "foo", assigns[:foo]
assert_equal "foo", assigns["foo"]
# but the assigned variable should not have its own keys stringified
expected_hash = { :foo => :bar }
assert_equal expected_hash, assigns(:foo_hash)
end
def test_view_assigns
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册