diff options
author | Xavier Noria <fxn@hashref.com> | 2013-08-27 00:24:17 -0700 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2013-08-27 00:24:17 -0700 |
commit | af3a69a783ea810d0045a6106f6c59573984f2ff (patch) | |
tree | a4272b7b2414f1986d82d37c5ac0593e12035f50 /activesupport | |
parent | 701664b56b69827bfb46a5acfddf81d3a81b5d09 (diff) | |
parent | b4a96686267c8bb261eca21c02acab9fd5f7ca96 (diff) | |
download | rails-af3a69a783ea810d0045a6106f6c59573984f2ff.tar.gz rails-af3a69a783ea810d0045a6106f6c59573984f2ff.tar.bz2 rails-af3a69a783ea810d0045a6106f6c59573984f2ff.zip |
Merge pull request #11636 from urbanautomaton/uppercase-nested-const-autoload-marking
`ActiveSupport::Dependencies`: consts in uppercase nestings not marked as autoloaded
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG.md | 5 | ||||
-rw-r--r-- | activesupport/lib/active_support/dependencies.rb | 2 | ||||
-rw-r--r-- | activesupport/test/autoloading_fixtures/html/some_class.rb | 4 | ||||
-rw-r--r-- | activesupport/test/dependencies_test.rb | 8 |
4 files changed, 18 insertions, 1 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 81c6246c5c..f15297f279 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,8 @@ +* Ensure that autoloaded constants in all-caps nestings are marked as + autoloaded. + + *Simon Coffey* + * Add String#remove(pattern) as a short-hand for the common pattern of String#gsub(pattern, '') *DHH* diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 73559bfe0e..db9f5d4baa 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -459,7 +459,7 @@ module ActiveSupport #:nodoc: if loaded.include?(expanded) raise "Circular dependency detected while autoloading constant #{qualified_name}" else - require_or_load(expanded) + require_or_load(expanded, qualified_name) raise LoadError, "Unable to autoload constant #{qualified_name}, expected #{file_path} to define it" unless from_mod.const_defined?(const_name, false) return from_mod.const_get(const_name) end diff --git a/activesupport/test/autoloading_fixtures/html/some_class.rb b/activesupport/test/autoloading_fixtures/html/some_class.rb new file mode 100644 index 0000000000..b43d15d891 --- /dev/null +++ b/activesupport/test/autoloading_fixtures/html/some_class.rb @@ -0,0 +1,4 @@ +module HTML + class SomeClass + end +end diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 68b6cc6e8c..9b84e75902 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -647,6 +647,14 @@ class DependenciesTest < ActiveSupport::TestCase Object.class_eval { remove_const :E } end + def test_constants_in_capitalized_nesting_marked_as_autoloaded + with_autoloading_fixtures do + ActiveSupport::Dependencies.load_missing_constant(HTML, "SomeClass") + + assert ActiveSupport::Dependencies.autoloaded?("HTML::SomeClass") + end + end + def test_unloadable with_autoloading_fixtures do Object.const_set :M, Module.new |