Add ApplicationController special case to Dependencies.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4910 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Nicholas Seckar
2006-09-02 21:13:30 +00:00
parent d0696d7641
commit 26f28e7cfa
3 changed files with 19 additions and 3 deletions

View File

@@ -1,5 +1,7 @@
*SVN*
* Add ApplicationController special case to Dependencies. [Nicholas Seckar]
* Don't pad remaining places with in_groups_of if specified padding value is false. [Marcel Molina Jr.]
* Fix cases where empty xml nodes weren't being translated to nil in Hash.create_from_xml [Rick Olson]

View File

@@ -123,6 +123,7 @@ module Dependencies #:nodoc:
def loadable_constants_for_path(path, bases = load_paths - load_once_paths)
path = $1 if path =~ /\A(.*)\.rb\Z/
expanded_path = File.expand_path(path)
bases.collect do |root|
expanded_root = File.expand_path root
next unless expanded_path.starts_with? expanded_root
@@ -131,8 +132,13 @@ module Dependencies #:nodoc:
nesting = nesting[1..-1] if nesting && nesting[0] == ?/
next if nesting.blank?
nesting.camelize
end.compact.uniq
names = [nesting.camelize]
# Special case: application.rb might define ApplicationControlller.
names << 'ApplicationController' if nesting == 'application'
names
end.flatten.compact.uniq
end
# Search for a file in load_paths matching the provided suffix.

View File

@@ -404,7 +404,7 @@ class DependenciesTest < Test::Unit::TestCase
assert ! Dependencies.autoloaded?("ModuleFolder::NestedClass")
assert ! Dependencies.autoloaded?(ModuleFolder)
ModuleFolder::NestedClass
1 if ModuleFolder::NestedClass # 1 if to avoid warning
assert ! Dependencies.autoloaded?(ModuleFolder::NestedClass)
end
ensure
@@ -412,4 +412,12 @@ class DependenciesTest < Test::Unit::TestCase
Dependencies.load_once_paths = []
end
def test_application_should_special_case_application_controller
with_loading 'autoloading_fixtures' do
require_dependency 'application'
assert_equal 10, ApplicationController
assert Dependencies.autoloaded?(:ApplicationController)
end
end
end