Permalink
Browse files

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

… to be a hash
  • Loading branch information...
willbryant committed Oct 15, 2011
1 parent bc4e7d4 commit 98af1173d2cc0d4b25043a5647a5cf73669747c5
@@ -7,7 +7,7 @@ def assigns(key = nil)
assigns = {}.with_indifferent_access
@controller.instance_variable_names.each do |ivar|
next if ActionController::Base.protected_instance_variables.include?(ivar)
- assigns[ivar[1..-1]] = @controller.instance_variable_get(ivar)
+ assigns.regular_writer(ivar[1..-1], @controller.instance_variable_get(ivar))
end
key.nil? ? assigns : assigns[key]
@@ -116,6 +116,7 @@ def delete_cookie
def test_assigns
@foo = "foo"
+ @foo_hash = {:foo => :bar}
render :nothing => true
end
@@ -245,6 +246,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_assert_tag_tag

0 comments on commit 98af117

Please sign in to comment.