提交 c8b82955 编写于 作者: E eileencodes

Refactor to remove DrawOnce module

We were doing extra work that could be pushed off to Integration test
and SharedRoutes. Creating an extra module isn't necessary when those
are created by their respective classes.
上级 e7007e38
......@@ -63,6 +63,10 @@ def env
SharedTestRoutes = ActionDispatch::Routing::RouteSet.new
SharedTestRoutes.draw do
get ':controller(/:action)'
end
module ActionDispatch
module SharedRoutes
def before_setup
......@@ -70,35 +74,10 @@ def before_setup
super
end
end
# Hold off drawing routes until all the possible controller classes
# have been loaded.
module DrawOnce
class << self
attr_accessor :drew
end
self.drew = false
def before_setup
super
return if DrawOnce.drew
SharedTestRoutes.draw do
get ':controller(/:action)'
end
ActionDispatch::IntegrationTest.app.routes.draw do
get ':controller(/:action)'
end
DrawOnce.drew = true
end
end
end
module ActiveSupport
class TestCase
include ActionDispatch::DrawOnce
if RUBY_ENGINE == "ruby" && PROCESS_COUNT > 0
parallelize_me!
end
......@@ -119,8 +98,6 @@ def call(env)
end
class ActionDispatch::IntegrationTest < ActiveSupport::TestCase
include ActionDispatch::SharedRoutes
def self.build_app(routes = nil)
RoutedRackApp.new(routes || ActionDispatch::Routing::RouteSet.new) do |middleware|
middleware.use ActionDispatch::ShowExceptions, ActionDispatch::PublicExceptions.new("#{FIXTURE_LOAD_PATH}/public")
......@@ -136,6 +113,10 @@ def self.build_app(routes = nil)
self.app = build_app
app.routes.draw do
get ':controller(/:action)'
end
# Stub Rails dispatcher so it does not get controller references and
# simply return the controller#action as Rack::Body.
class StubDispatcher < ::ActionDispatch::Routing::RouteSet::Dispatcher
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册