diff options
author | Jan Habermann <jan@habermann.io> | 2018-10-18 19:05:20 +0200 |
---|---|---|
committer | Jan Habermann <jan@habermann.io> | 2018-10-28 16:34:50 +0100 |
commit | e302725751fc4bdb26aa3d28ca5d934ec21319f9 (patch) | |
tree | deebadcfbf219a1c38419a464cb636555773d7bf /activesupport/test/dependencies_test.rb | |
parent | 3295e23755744b7f9426d752481bb928fb02a89e (diff) | |
download | rails-e302725751fc4bdb26aa3d28ca5d934ec21319f9.tar.gz rails-e302725751fc4bdb26aa3d28ca5d934ec21319f9.tar.bz2 rails-e302725751fc4bdb26aa3d28ca5d934ec21319f9.zip |
Improve the logic that detects non-autoloaded constants
If you require `nokogiri` from `app/models/user.rb`, dependencies.rb
does not mark `Nokogiri` as an autoloaded constant, as expected.
But the logic to detect these non-autoloaded constants is incomplete.
See the tests defined in the patch for some cases incorrectly handled.
Diffstat (limited to 'activesupport/test/dependencies_test.rb')
-rw-r--r-- | activesupport/test/dependencies_test.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index e144971e9f..9f2755a25c 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -282,6 +282,32 @@ class DependenciesTest < ActiveSupport::TestCase remove_constants(:ModuleFolder) end + def test_module_with_nested_class_requiring_lib_class + with_autoloading_fixtures do + ModuleFolder::NestedWithRequire + + assert defined?(ModuleFolder::LibClass) + assert_not ActiveSupport::Dependencies.autoloaded_constants.include?("ModuleFolder::LibClass") + assert_not ActiveSupport::Dependencies.autoloaded_constants.include?("ConstFromLib") + end + ensure + remove_constants(:ModuleFolder) + remove_constants(:ConstFromLib) + end + + def test_module_with_nested_class_and_parent_requiring_lib_class + with_autoloading_fixtures do + NestedWithRequireParent + + assert defined?(ModuleFolder::LibClass) + assert_not ActiveSupport::Dependencies.autoloaded_constants.include?("ModuleFolder::LibClass") + assert_not ActiveSupport::Dependencies.autoloaded_constants.include?("ConstFromLib") + end + ensure + remove_constants(:ModuleFolder) + remove_constants(:ConstFromLib) + end + def test_directories_may_manifest_as_nested_classes with_autoloading_fixtures do assert_kind_of Class, ClassFolder |