mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Integration requests should work in contexts without setup and teardown
This commit is contained in:
parent
70c2777d1c
commit
95333e1317
2 changed files with 26 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue