Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

… to be a hash
  • Loading branch information...
commit ee9fc421da8c38e09902816a9e1221a4b641e028 1 parent 960882f
@willbryant authored
View
3  actionpack/lib/action_dispatch/testing/test_process.rb
@@ -4,7 +4,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
View
5 actionpack/test/controller/test_test.rb
@@ -120,6 +120,7 @@ def delete_cookie
def test_assigns
@foo = "foo"
+ @foo_hash = {:foo => :bar}
render :nothing => true
end
@@ -265,6 +266,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
Please sign in to comment.
Something went wrong with that request. Please try again.