mirror of
https://github.com/github/rails.git
synced 2026-01-31 01:08:19 -05:00
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
This commit is contained in:
@@ -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 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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user