From 8d809e724ac3e5ebc7f35e40f95632c853c68d89 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Sat, 23 Sep 2006 17:25:06 +0000 Subject: Clear the cache of possible controllers whenever Routes are reloaded. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5169 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/routing_test.rb | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'actionpack/test/controller/routing_test.rb') diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index ee2ef63377..1dc61df5fb 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -18,8 +18,8 @@ class LegacyRouteSetTests < Test::Unit::TestCase attr_reader :rs def setup @rs = ::ActionController::Routing::RouteSet.new - ActionController::Routing.use_controllers! %w(content admin/user admin/news_feed) @rs.draw {|m| m.connect ':controller/:action/:id' } + ActionController::Routing.use_controllers! %w(content admin/user admin/news_feed) end def test_default_setup @@ -1657,9 +1657,35 @@ class RoutingTest < Test::Unit::TestCase if true_controller_paths ActionController::Routing.controller_paths = true_controller_paths end + ActionController::Routing.use_controllers! nil Object.send(:remove_const, :RAILS_ROOT) rescue nil end + def test_possible_controllers_are_reset_on_each_load + true_possible_controllers = ActionController::Routing.possible_controllers + true_controller_paths = ActionController::Routing.controller_paths + + ActionController::Routing.use_controllers! nil + root = File.dirname(__FILE__) + '/controller_fixtures' + + ActionController::Routing.controller_paths = [] + assert_equal [], ActionController::Routing.possible_controllers + + ActionController::Routing::Routes.load! + ActionController::Routing.controller_paths = [ + root, root + '/app/controllers', root + '/vendor/plugins/bad_plugin/lib' + ] + + assert_equal ["admin/user", "plugin", "user"], ActionController::Routing.possible_controllers.sort + ensure + ActionController::Routing.controller_paths = true_controller_paths + ActionController::Routing.use_controllers! true_possible_controllers + Object.send(:remove_const, :RAILS_ROOT) rescue nil + + ActionController::Routing::Routes.clear! + ActionController::Routing::Routes.load_routes! + end + def test_with_controllers c = %w(admin/accounts admin/users account pages) ActionController::Routing.with_controllers c do -- cgit v1.2.3