From 7441b19d0c6f944b8547725f1f51349c79608576 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Tue, 5 Sep 2006 23:36:14 +0000 Subject: [PATCH] Fix logic error in determining what was loaded by a given file. Closes #6039. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5035 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/CHANGELOG | 2 ++ .../lib/active_support/dependencies.rb | 2 +- activesupport/test/dependencies_test.rb | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index 004a5b00df..54f9b4e4cc 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fix logic error in determining what was loaded by a given file. Closes #6039. [Nicholas Seckar] + * Equate Kernel.const_missing with Object.const_missing. Fixes #5988. [Nicholas Seckar] * Add ApplicationController special case to Dependencies. [Nicholas Seckar] diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index bccbd549b1..1b027aa75b 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -188,7 +188,7 @@ def load_file(path, const_paths = loadable_constants_for_path(path)) result = load path - newly_defined_paths = const_paths.select(&method(:qualified_const_defined?)) + newly_defined_paths = undefined_before.select(&method(:qualified_const_defined?)) autoloaded_constants.concat newly_defined_paths autoloaded_constants.uniq! log "loading #{path} defined #{newly_defined_paths * ', '}" unless newly_defined_paths.empty? diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index c80e35c5f6..fcd2889ac2 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -428,4 +428,22 @@ def test_const_missing_on_kernel_should_fallback_to_object end end + def test_preexisting_constants_are_not_marked_as_autoloaded + with_loading 'autoloading_fixtures' do + require_dependency 'e' + assert Dependencies.autoloaded?(:E) + Dependencies.clear + end + + Object.const_set :E, Class.new + with_loading 'autoloading_fixtures' do + require_dependency 'e' + assert ! Dependencies.autoloaded?(:E), "E shouldn't be marked autoloaded!" + Dependencies.clear + end + + ensure + Object.send :remove_const, :E if Object.const_defined?(:E) + end + end