提交 6442c90f 编写于 作者: R Rafael Mendonça França

Merge pull request #18298 from brainopia/integration_requests_without_setup

Integration requests should work in contexts without setup and teardown
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册