diff options
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/dependencies.rb | 2 | ||||
-rw-r--r-- | activesupport/test/dependencies_test.rb | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index e845408137..f5d047ee07 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -155,7 +155,7 @@ module Dependencies #:nodoc: name_error = NameError.new("uninitialized constant #{qualified_name}") file_path = search_for_autoload_file(path_suffix) - if file_path # We found a matching file to load + if file_path #&& ! loaded.include?(file_path) # We found a matching file to load require_or_load file_path, qualified_name raise LoadError, "Expected #{file_path} to define #{qualified_name}" unless from_mod.const_defined?(const_name) return from_mod.const_get(const_name) diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index bf9aaac8c1..b607093e8e 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -300,4 +300,13 @@ class DependenciesTest < Test::Unit::TestCase end end + def test_const_missing_should_not_double_load + with_loading 'autoloading_fixtures' do + require_dependency 'counting_loader' + assert_equal 1, $counting_loaded_times + ModuleFolder + assert_equal 1, $counting_loaded_times + end + end + end |