From fe1f11a1dc0ca50b45dae21eb53cc1f0fd5dfdf8 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Tue, 17 Mar 2009 15:05:34 +0000 Subject: [PATCH] Return the already defined constant instead of raising an exception --- activesupport/lib/active_support/dependencies.rb | 2 +- activesupport/test/dependencies_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 2badad5..e0f10c6 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -414,7 +414,7 @@ module ActiveSupport #:nodoc: raise ArgumentError, "A copy of #{from_mod} has been removed from the module tree but is still active!" end - raise ArgumentError, "#{from_mod} is not missing constant #{const_name}!" if uninherited_const_defined?(from_mod, const_name) + return from_mod.const_get(const_name) if uninherited_const_defined?(from_mod, const_name) qualified_name = qualified_name_for from_mod, const_name path_suffix = qualified_name.underscore diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index a21f094..4b9d081 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -382,7 +382,7 @@ class DependenciesTest < Test::Unit::TestCase with_loading 'autoloading_fixtures' do require_dependency '././counting_loader' assert_equal 1, $counting_loaded_times - assert_raise(ArgumentError) { ActiveSupport::Dependencies.load_missing_constant Object, :CountingLoader } + assert_equal CountingLoader, ActiveSupport::Dependencies.load_missing_constant(Object, :CountingLoader) assert_equal 1, $counting_loaded_times end end -- 1.5.4.5