Permalink
Browse files

Check for nil name also. Closes #6561.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5814 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 7ed7930 commit cbe0c3c54f342ec74ced50f272be3f8d6ff7a2dd @jeremy jeremy committed Dec 31, 2006
Showing with 8 additions and 2 deletions.
  1. +2 −1 activesupport/lib/active_support/dependencies.rb
  2. +6 −1 activesupport/test/dependencies_test.rb
@@ -278,7 +278,8 @@ def remove_unloadable_constants!
# Determine if the given constant has been automatically loaded.
def autoloaded?(desc)
- return false if desc.is_a?(Module) && desc.name.empty? # Empty name => anonymous module.
+ # No name => anonymous module.
+ return false if desc.is_a?(Module) && desc.name.blank?
name = to_constant_name desc
return false unless qualified_const_defined? name
return autoloaded_constants.include?(name)
@@ -305,7 +305,12 @@ def test_autoloaded?
assert Dependencies.autoloaded?("::ModuleFolder")
assert Dependencies.autoloaded?(:ModuleFolder)
- assert ! Dependencies.autoloaded?(Module.new)
+ # Anonymous modules aren't autoloaded.
+ assert !Dependencies.autoloaded?(Module.new)
+
+ nil_name = Module.new
+ def nil_name.name() nil end
+ assert !Dependencies.autoloaded?(nil_name)
Object.send :remove_const, :ModuleFolder
end

0 comments on commit cbe0c3c

Please sign in to comment.