diff options
author | brainopia <brainopia@evilmartians.com> | 2015-01-02 15:22:30 +0300 |
---|---|---|
committer | brainopia <brainopia@evilmartians.com> | 2015-01-02 16:52:32 +0300 |
commit | 95333e131708d0500e03e3ed1b076f4817f04fbb (patch) | |
tree | 185193ce1e1971d2addf35d626e8849e685d567d /actionpack | |
parent | 70c2777d1c2bfaf538c5bc892a5c3f96f67291f1 (diff) | |
download | rails-95333e131708d0500e03e3ed1b076f4817f04fbb.tar.gz rails-95333e131708d0500e03e3ed1b076f4817f04fbb.tar.bz2 rails-95333e131708d0500e03e3ed1b076f4817f04fbb.zip |
Integration requests should work in contexts without setup and teardown
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 3 | ||||
-rw-r--r-- | actionpack/test/controller/integration_test.rb | 24 |
2 files changed, 26 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index b9172f8fa3..9a77f179d3 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -67,7 +67,8 @@ module ActionController def reset_template_assertion RENDER_TEMPLATE_INSTANCE_VARIABLES.each do |instance_variable| - instance_variable_get("@_#{instance_variable}").clear + ivar = instance_variable_get("@_#{instance_variable}") + ivar.clear if ivar end end diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index d6219b7626..5535c7ae78 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -850,3 +850,27 @@ class IntegrationWithRoutingTest < ActionDispatch::IntegrationTest end end end + +# to work in contexts like rspec before(:all) +class IntegrationRequestsWithoutSetup < ActionDispatch::IntegrationTest + self._setup_callbacks = [] + self._teardown_callbacks = [] + + class FooController < ActionController::Base + def ok + cookies[:key] = 'ok' + render plain: 'ok' + end + end + + def test_request + with_routing do |routes| + routes.draw { get ':action' => FooController } + get '/ok' + + assert_response 200 + assert_equal 'ok', response.body + assert_equal 'ok', cookies['key'] + end + end +end |