mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove session to allow with_routing
to be called twice.
Fixes: https://github.com/rails/rails/issues/16814
This commit is contained in:
parent
00ae750b23
commit
76f5a9afb3
3 changed files with 41 additions and 0 deletions
|
@ -326,6 +326,10 @@ module ActionDispatch
|
|||
@integration_session = Integration::Session.new(app)
|
||||
end
|
||||
|
||||
def remove! # :nodoc:
|
||||
@integration_session = nil
|
||||
end
|
||||
|
||||
%w(get post patch put head delete cookies assigns
|
||||
xml_http_request xhr get_via_redirect post_via_redirect).each do |method|
|
||||
define_method(method) do |*args|
|
||||
|
|
|
@ -194,6 +194,7 @@ class ActionDispatch::IntegrationTest < ActiveSupport::TestCase
|
|||
yield temporary_routes
|
||||
ensure
|
||||
self.class.app = old_app
|
||||
self.remove!
|
||||
silence_warnings { Object.const_set(:SharedTestRoutes, old_routes) }
|
||||
end
|
||||
|
||||
|
|
|
@ -814,3 +814,39 @@ class HeadWithStatusActionIntegrationTest < ActionDispatch::IntegrationTest
|
|||
assert_response :ok
|
||||
end
|
||||
end
|
||||
|
||||
class IntegrationWithRoutingTest < ActionDispatch::IntegrationTest
|
||||
class FooController < ActionController::Base
|
||||
def index
|
||||
render plain: 'ok'
|
||||
end
|
||||
end
|
||||
|
||||
def test_with_routing_resets_session
|
||||
klass_namespace = self.class.name.underscore
|
||||
|
||||
with_routing do |routes|
|
||||
routes.draw do
|
||||
namespace klass_namespace do
|
||||
resources :foo, path: '/with'
|
||||
end
|
||||
end
|
||||
|
||||
get '/integration_with_routing_test/with'
|
||||
assert_response 200
|
||||
assert_equal 'ok', response.body
|
||||
end
|
||||
|
||||
with_routing do |routes|
|
||||
routes.draw do
|
||||
namespace klass_namespace do
|
||||
resources :foo, path: '/routing'
|
||||
end
|
||||
end
|
||||
|
||||
get '/integration_with_routing_test/routing'
|
||||
assert_response 200
|
||||
assert_equal 'ok', response.body
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue