From f1966337fa744a1c62054120693072ebabe996a8 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 1 Sep 2010 14:12:06 +0100 Subject: Add before_remove_const callback to ActiveSupport::Dependencies.remove_unloadable_constants! Signed-off-by: Xavier Noria --- activesupport/test/dependencies_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'activesupport/test') diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 77b885dc3d..bc7f597f1d 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -574,6 +574,17 @@ class DependenciesTest < Test::Unit::TestCase end end + def test_unloadable_constants_should_receive_callback + Object.const_set :C, Class.new + C.unloadable + C.expects(:before_remove_const).once + assert C.respond_to?(:before_remove_const) + ActiveSupport::Dependencies.clear + assert !defined?(C) + ensure + Object.class_eval { remove_const :C } if defined?(C) + end + def test_new_contants_in_without_constants assert_equal [], (ActiveSupport::Dependencies.new_constants_in(Object) { }) assert ActiveSupport::Dependencies.constant_watch_stack.all? {|k,v| v.empty? } -- cgit v1.2.3