Merge pull request #18298 from brainopia/integration_requests_without_setup
Integration requests should work in contexts without setup and teardown
This commit is contained in:
commit
6442c90f09
@ -67,7 +67,8 @@ def process(*args)
|
||||
|
||||
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 @@ def test_with_routing_resets_session
|
||||
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 New Issue
Block a user