diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 4 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 28 |
3 files changed, 32 insertions, 2 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index f8710fc893..bd52be4968 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -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] diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index c309878dbd..9fe886d958 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -243,10 +243,11 @@ module ActionController 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 @@ module ActionController end def load! + Routing.use_controllers! nil # Clear the controller cache so we may discover new ones clear! load_routes! named_routes.install 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 |