Permalink
Browse files

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
  • Loading branch information...
1 parent 704443d commit 8d809e724ac3e5ebc7f35e40f95632c853c68d89 @seckar seckar committed Sep 23, 2006
Showing with 32 additions and 2 deletions.
  1. +2 −0 actionpack/CHANGELOG
  2. +3 −1 actionpack/lib/action_controller/routing.rb
  3. +27 −1 actionpack/test/controller/routing_test.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* Clear the cache of possible controllers whenever Routes are reloaded. [Nicholas Seckar]
+
* Filters overhaul including meantime filter support using around filters + blocks. #5949 [Martin Emde, Roman Le Negrate, Stefan Kaes, Jeremy Kemper]
* Update RJS render tests. [sam]
@@ -243,10 +243,11 @@ module Routing
class << self
def with_controllers(names)
+ prior_controllers = @possible_controllers
use_controllers! names
yield
ensure
- use_controllers! nil
+ use_controllers! prior_controllers
end
def normalize_paths(paths)
@@ -1127,6 +1128,7 @@ def empty?
end
def load!
+ Routing.use_controllers! nil # Clear the controller cache so we may discover new ones
clear!
load_routes!
named_routes.install
@@ -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 @@ def test_possible_controllers
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

0 comments on commit 8d809e7

Please sign in to comment.