mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
assigns(:foo) should not convert @foo's keys to strings if it happens to be a hash
This commit is contained in:
parent
2f689d462d
commit
185c3dbc6a
2 changed files with 7 additions and 1 deletions
|
@ -5,7 +5,8 @@ require 'active_support/core_ext/hash/indifferent_access'
|
|||
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 @@ XML
|
|||
|
||||
def test_assigns
|
||||
@foo = "foo"
|
||||
@foo_hash = {:foo => :bar}
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
|
@ -292,6 +293,10 @@ XML
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue