aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/testing/assertions/routing.rb
diff options
context:
space:
mode:
authorRizwan Reza <rizwanreza@gmail.com>2010-03-28 12:04:00 +0430
committerRizwan Reza <rizwanreza@gmail.com>2010-03-28 12:04:00 +0430
commitb4c91de9462f59d6395c7c871aafa3301afdc383 (patch)
treefadcaf603a6f473e8ccd52070a1f3b4f957c34cb /actionpack/lib/action_dispatch/testing/assertions/routing.rb
parent4b4f69b9bfbd33556e23262f57cf6d944dfd9f63 (diff)
parent66d57d7ba83df52ff1e0485c89f6192c2f84c6b8 (diff)
downloadrails-b4c91de9462f59d6395c7c871aafa3301afdc383.tar.gz
rails-b4c91de9462f59d6395c7c871aafa3301afdc383.tar.bz2
rails-b4c91de9462f59d6395c7c871aafa3301afdc383.zip
Merge remote branch 'rails/master'
Diffstat (limited to 'actionpack/lib/action_dispatch/testing/assertions/routing.rb')
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/routing.rb18
1 files changed, 16 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb
index 1d7e8090e4..1bb81ede3b 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb
@@ -145,11 +145,25 @@ module ActionDispatch
old_routes, @router = @router, ActionDispatch::Routing::RouteSet.new
old_controller, @controller = @controller, @controller.clone if @controller
_router = @router
- @controller.singleton_class.send(:send, :include, @router.url_helpers) if @controller
+
+ # Unfortunately, there is currently an abstraction leak between AC::Base
+ # and AV::Base which requires having the URL helpers in both AC and AV.
+ # To do this safely at runtime for tests, we need to bump up the helper serial
+ # to that the old AV subclass isn't cached.
+ #
+ # TODO: Make this unnecessary
+ if @controller
+ @controller.singleton_class.send(:include, _router.url_helpers)
+ @controller.view_context_class = Class.new(@controller.view_context_class) do
+ include _router.url_helpers
+ end
+ end
yield @router
ensure
@router = old_routes
- @controller = old_controller if @controller
+ if @controller
+ @controller = old_controller
+ end
end
# ROUTES TODO: These assertions should really work in an integration context