aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorSimon Coffey <simon@tribesports.com>2013-07-26 17:37:00 +0100
committerSimon Coffey <simon@tribesports.com>2013-08-27 08:20:33 +0100
commitb4a96686267c8bb261eca21c02acab9fd5f7ca96 (patch)
treea4272b7b2414f1986d82d37c5ac0593e12035f50 /activesupport/test
parent701664b56b69827bfb46a5acfddf81d3a81b5d09 (diff)
downloadrails-b4a96686267c8bb261eca21c02acab9fd5f7ca96.tar.gz
rails-b4a96686267c8bb261eca21c02acab9fd5f7ca96.tar.bz2
rails-b4a96686267c8bb261eca21c02acab9fd5f7ca96.zip
Ensure all-caps nested consts marked as autoloaded
Previously, an autoloaded constant `HTML::SomeClass` would not be marked as autoloaded by AS::Dependencies. This is because the `#loadable_constants_for_path` method uses `String#camelize` on the inferred file path, which in turn means that, unless otherwise directed, AS::Dependencies watches for loaded constants in the `Html` namespace. By passing the original qualified constant name to `#load_or_require`, this inference step is avoided, and the new constant is picked up in the correct namespace.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/autoloading_fixtures/html/some_class.rb4
-rw-r--r--activesupport/test/dependencies_test.rb8
2 files changed, 12 insertions, 0 deletions
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