diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-02-20 09:05:56 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-02-20 09:05:56 -0800 |
commit | eff507f44dea66119799ae51910d5786e21d6c81 (patch) | |
tree | fe4884d6b1f524ca721f3c6a5ee6522e93bec013 | |
parent | 977183a8100257f98eed6b5cdf71618190c28aad (diff) | |
parent | 185c3dbc6ab845edfc94e8d38ef5be11c417dd81 (diff) | |
download | rails-eff507f44dea66119799ae51910d5786e21d6c81.tar.gz rails-eff507f44dea66119799ae51910d5786e21d6c81.tar.bz2 rails-eff507f44dea66119799ae51910d5786e21d6c81.zip |
Merge pull request #5082 from willbryant/assigns_should_not_stringify_values_master
assigns(:foo) should not convert @foo's keys to strings if it happens to be a hash
-rw-r--r-- | actionpack/lib/action_dispatch/testing/test_process.rb | 3 | ||||
-rw-r--r-- | actionpack/test/controller/test_case_test.rb | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/testing/test_process.rb b/actionpack/lib/action_dispatch/testing/test_process.rb index b08ff41950..3a6d081721 100644 --- a/actionpack/lib/action_dispatch/testing/test_process.rb +++ b/actionpack/lib/action_dispatch/testing/test_process.rb @@ -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 diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index c957df88b3..ecba9fed22 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -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 |