mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #11636 from urbanautomaton/uppercase-nested-const-autoload-marking
`ActiveSupport::Dependencies`: consts in uppercase nestings not marked as autoloaded
This commit is contained in:
commit
af3a69a783
4 changed files with 18 additions and 1 deletions
|
@ -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*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
module HTML
|
||||
class SomeClass
|
||||
end
|
||||
end
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue