diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-01-02 10:59:59 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-01-02 10:59:59 -0300 |
commit | 6442c90f098f7095ada0cd66bb7291b6798a5583 (patch) | |
tree | 1d4df68e7784018a658a1405cb0838ff34fac7d6 | |
parent | 9598c9655f04b3bf6dfc245437ad5a09f23c792c (diff) | |
parent | 95333e131708d0500e03e3ed1b076f4817f04fbb (diff) | |
download | rails-6442c90f098f7095ada0cd66bb7291b6798a5583.tar.gz rails-6442c90f098f7095ada0cd66bb7291b6798a5583.tar.bz2 rails-6442c90f098f7095ada0cd66bb7291b6798a5583.zip |
Merge pull request #18298 from brainopia/integration_requests_without_setup
Integration requests should work in contexts without setup and teardown
-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 |