aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-10-03 23:55:35 -0500
committerJoshua Peek <josh@joshpeek.com>2009-10-03 23:55:35 -0500
commit86d059002291b4cc320a86fc3702e40375e0b811 (patch)
treeedbdb7aa535641225d5feed42cd92b226cb1522d
parent86ed58d9121844e2d881be67e2d845ae721f72e7 (diff)
downloadrails-86d059002291b4cc320a86fc3702e40375e0b811.tar.gz
rails-86d059002291b4cc320a86fc3702e40375e0b811.tar.bz2
rails-86d059002291b4cc320a86fc3702e40375e0b811.zip
Only draw default route once
-rw-r--r--actionpack/test/abstract_unit.rb59
1 files changed, 37 insertions, 22 deletions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index 950c85a34b..1214d608a4 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -53,6 +53,43 @@ ORIGINAL_LOCALES = I18n.available_locales.map {|locale| locale.to_s }.sort
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
FIXTURES = Pathname.new(FIXTURE_LOAD_PATH)
+module SetupOnce
+ extend ActiveSupport::Concern
+
+ included do
+ cattr_accessor :setup_once_block
+ self.setup_once_block = nil
+
+ setup :run_setup_once
+ end
+
+ module ClassMethods
+ def setup_once(&block)
+ self.setup_once_block = block
+ end
+ end
+
+ private
+ def run_setup_once
+ if self.setup_once_block
+ self.setup_once_block.call
+ self.setup_once_block = nil
+ end
+ end
+end
+
+class ActiveSupport::TestCase
+ include SetupOnce
+
+ # Hold off drawing routes until all the possible controller classes
+ # have been loaded.
+ setup_once do
+ ActionController::Routing::Routes.draw do |map|
+ map.connect ':controller/:action/:id'
+ end
+ end
+end
+
class ActionController::IntegrationTest < ActiveSupport::TestCase
def self.build_app(routes = nil)
ActionDispatch::MiddlewareStack.new { |middleware|
@@ -81,22 +118,6 @@ class ActionController::IntegrationTest < ActiveSupport::TestCase
ActionController::Routing.const_set(:Routes, real_routes) if real_routes
self.class.app = self.class.build_app
end
-
- setup do
- ActionController::Routing::Routes.draw do |map|
- map.connect ':controller/:action/:id'
- end
- end
-end
-
-module ActionView
- class TestCase
- setup do
- ActionController::Routing::Routes.draw do |map|
- map.connect ':controller/:action/:id'
- end
- end
- end
end
# Temporary base class
@@ -172,12 +193,6 @@ module ActionController
class TestCase
include TestProcess
- setup do
- ActionController::Routing::Routes.draw do |map|
- map.connect ':controller/:action/:id'
- end
- end
-
def assert_template(options = {}, message = nil)
validate_request!