Skip to content

Commit

Permalink
assigns(:foo) should not convert @foo's keys to strings if it happens…
Browse files Browse the repository at this point in the history
… to be a hash
  • Loading branch information
willbryant committed Oct 15, 2011
1 parent bc4e7d4 commit 98af117
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/testing/test_process.rb
Expand Up @@ -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]
Expand Down
5 changes: 5 additions & 0 deletions actionpack/test/controller/test_test.rb
Expand Up @@ -116,6 +116,7 @@ def delete_cookie

def test_assigns
@foo = "foo"
@foo_hash = {:foo => :bar}
render :nothing => true
end

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 98af117

Please sign in to comment.