From bff4d8d165486797227c5933e93a62e7f2c15d98 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Thu, 15 Nov 2012 04:33:17 +0100 Subject: dependencies no longer trigger Kernel#autoload in remove_const [fixes #8213] --- .../test/autoloading_fixtures/should_not_be_required.rb | 1 + activesupport/test/dependencies_test.rb | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 activesupport/test/autoloading_fixtures/should_not_be_required.rb (limited to 'activesupport/test') diff --git a/activesupport/test/autoloading_fixtures/should_not_be_required.rb b/activesupport/test/autoloading_fixtures/should_not_be_required.rb new file mode 100644 index 0000000000..1fcf170cc5 --- /dev/null +++ b/activesupport/test/autoloading_fixtures/should_not_be_required.rb @@ -0,0 +1 @@ +ShouldNotBeAutoloaded = 0 diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 670a04e5df..6e5a6f71e2 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -928,6 +928,16 @@ class DependenciesTest < ActiveSupport::TestCase assert ! defined?(DeleteMe) end + def test_remove_constant_does_not_trigger_loading_autoloads + constant = 'ShouldNotBeAutoloaded' + Object.class_eval do + autoload constant, File.expand_path('../autoloading_fixtures/should_not_be_required', __FILE__) + end + ActiveSupport::Dependencies.remove_constant(constant) + + assert Object.autoload?(constant), "Kernel#autoload of #{constant} has been triggered by remove_const" + end + def test_load_once_constants_should_not_be_unloaded with_autoloading_fixtures do ActiveSupport::Dependencies.autoload_once_paths = ActiveSupport::Dependencies.autoload_paths -- cgit v1.2.3