aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2015-08-08 10:15:35 -0400
committereileencodes <eileencodes@gmail.com>2015-08-08 10:15:35 -0400
commitc8b82955836cfff2795464e8acc7592e3c192a51 (patch)
treec6c367f98bd54b3f722205976083834191b60d13 /actionpack/test
parente7007e384c2ccfda3228c1ccdb1331e89fb17f4d (diff)
downloadrails-c8b82955836cfff2795464e8acc7592e3c192a51.tar.gz
rails-c8b82955836cfff2795464e8acc7592e3c192a51.tar.bz2
rails-c8b82955836cfff2795464e8acc7592e3c192a51.zip
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.
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract_unit.rb35
1 files changed, 8 insertions, 27 deletions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index 771df5a0b2..09d55133e9 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -63,6 +63,10 @@ FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
SharedTestRoutes = ActionDispatch::Routing::RouteSet.new
+SharedTestRoutes.draw do
+ get ':controller(/:action)'
+end
+
module ActionDispatch
module SharedRoutes
def before_setup
@@ -70,35 +74,10 @@ module ActionDispatch
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 @@ class RoutedRackApp
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 @@ class ActionDispatch::IntegrationTest < ActiveSupport::TestCase
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