diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-08-09 14:46:57 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-08-09 14:50:27 -0700 |
commit | c63d17c2be04882cc0c7aed5cf2b5ba2f1ef313d (patch) | |
tree | f7e52a872d16655c1dd25ddb25ba5831f6c86bbf /actionpack | |
parent | 1e8c0a29d0190c375580c594479f517f4c9aa4bf (diff) | |
download | rails-c63d17c2be04882cc0c7aed5cf2b5ba2f1ef313d.tar.gz rails-c63d17c2be04882cc0c7aed5cf2b5ba2f1ef313d.tar.bz2 rails-c63d17c2be04882cc0c7aed5cf2b5ba2f1ef313d.zip |
push drawing once to it's own module
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/test/abstract_unit.rb | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index f7a3f9a533..b914bbce4d 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -85,31 +85,6 @@ module RenderERBUtils end end -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 - SharedTestRoutes = ActionDispatch::Routing::RouteSet.new module ActionDispatch @@ -119,14 +94,19 @@ module ActionDispatch super end end -end -module ActiveSupport - class TestCase - include SetupOnce - # Hold off drawing routes until all the possible controller classes - # have been loaded. - setup_once do + # 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 @@ -134,10 +114,18 @@ module ActiveSupport ActionDispatch::IntegrationTest.app.routes.draw do get ':controller(/:action)' end + + DrawOnce.drew = true end end end +module ActiveSupport + class TestCase + include ActionDispatch::DrawOnce + end +end + class RoutedRackApp attr_reader :routes |