mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix loadable_constants_for_path to handle load paths that do not end with a slash.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5053 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
5a5f85d5be
commit
93659978d5
3 changed files with 16 additions and 8 deletions
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Fix loadable_constants_for_path to handle load paths that do not end with a slash. [Nicholas Seckar]
|
||||
|
||||
* Fix logic error in determining what was loaded by a given file. Closes #6039. [Nicholas Seckar]
|
||||
|
||||
* Equate Kernel.const_missing with Object.const_missing. Fixes #5988. [Nicholas Seckar]
|
||||
|
|
|
@ -125,19 +125,18 @@ module Dependencies #:nodoc:
|
|||
expanded_path = File.expand_path(path)
|
||||
|
||||
bases.collect do |root|
|
||||
expanded_root = File.expand_path root
|
||||
next unless expanded_path.starts_with? expanded_root
|
||||
expanded_root = File.expand_path(root)
|
||||
next unless %r{\A#{Regexp.escape(expanded_root)}(/|\\)} =~ expanded_path
|
||||
|
||||
nesting = expanded_path[(expanded_root.size)..-1]
|
||||
nesting = nesting[1..-1] if nesting && nesting[0] == ?/
|
||||
next if nesting.blank?
|
||||
|
||||
names = [nesting.camelize]
|
||||
|
||||
# Special case: application.rb might define ApplicationControlller.
|
||||
names << 'ApplicationController' if nesting == 'application'
|
||||
|
||||
names
|
||||
[
|
||||
nesting.camelize,
|
||||
# Special case: application.rb might define ApplicationControlller.
|
||||
('ApplicationController' if nesting == 'application')
|
||||
]
|
||||
end.flatten.compact.uniq
|
||||
end
|
||||
|
||||
|
|
|
@ -250,6 +250,13 @@ class DependenciesTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_loadable_constants_with_load_path_without_trailing_slash
|
||||
path = File.dirname(__FILE__) + '/autoloading_fixtures/class_folder/inline_class.rb'
|
||||
with_loading 'autoloading_fixtures/class/' do
|
||||
assert_equal [], Dependencies.loadable_constants_for_path(path)
|
||||
end
|
||||
end
|
||||
|
||||
def test_qualified_const_defined
|
||||
assert Dependencies.qualified_const_defined?("Object")
|
||||
assert Dependencies.qualified_const_defined?("::Object")
|
||||
|
|
Loading…
Reference in a new issue