aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/abstract_unit.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-10-03 20:45:49 -0500
committerJoshua Peek <josh@joshpeek.com>2009-10-03 20:45:49 -0500
commit84e94551f62d3bcbc71f1c6f3fda738342d984e2 (patch)
tree910865aabfd681bc4b71f3dc406f858d41ba963b /actionpack/test/abstract_unit.rb
parent89630a7c2c3d0f625742e2b84ec28479ff3ecef9 (diff)
downloadrails-84e94551f62d3bcbc71f1c6f3fda738342d984e2.tar.gz
rails-84e94551f62d3bcbc71f1c6f3fda738342d984e2.tar.bz2
rails-84e94551f62d3bcbc71f1c6f3fda738342d984e2.zip
Add custom "with_routing" to internal tests to fix reseting session after using
with_routing. This only affects our internal AP tests.
Diffstat (limited to 'actionpack/test/abstract_unit.rb')
-rw-r--r--actionpack/test/abstract_unit.rb33
1 files changed, 27 insertions, 6 deletions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index aef3dd6165..b72dd4dd0f 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -53,12 +53,33 @@ ORIGINAL_LOCALES = I18n.available_locales.map {|locale| locale.to_s }.sort
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
class ActionController::IntegrationTest < ActiveSupport::TestCase
- @@app = ActionDispatch::MiddlewareStack.new { |middleware|
- middleware.use "ActionDispatch::ShowExceptions"
- middleware.use "ActionDispatch::Callbacks"
- middleware.use "ActionDispatch::ParamsParser"
- middleware.use "Rack::Head"
- }.build(ActionController::Routing::Routes)
+ def self.build_app(routes = nil)
+ ActionDispatch::MiddlewareStack.new { |middleware|
+ middleware.use "ActionDispatch::ShowExceptions"
+ middleware.use "ActionDispatch::Callbacks"
+ middleware.use "ActionDispatch::ParamsParser"
+ middleware.use "Rack::Head"
+ }.build(routes || ActionController::Routing::Routes)
+ end
+
+ self.app = build_app
+
+ def with_routing(&block)
+ real_routes = ActionController::Routing::Routes
+ ActionController::Routing.module_eval { remove_const :Routes }
+
+ temporary_routes = ActionController::Routing::RouteSet.new
+ self.class.app = self.class.build_app(temporary_routes)
+ ActionController::Routing.module_eval { const_set :Routes, temporary_routes }
+
+ yield temporary_routes
+ ensure
+ if ActionController::Routing.const_defined? :Routes
+ ActionController::Routing.module_eval { remove_const :Routes }
+ end
+ ActionController::Routing.const_set(:Routes, real_routes) if real_routes
+ self.class.app = self.class.build_app
+ end
end
module ActionView