From 1bce58b31289362d62863ad0600b924858a11e34 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Thu, 2 Feb 2006 05:41:00 +0000 Subject: Add Reloadable::OnlySubclasses which handles the common case where a base class should not be reloaded, but its subclasses should be. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3521 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/reloadable_test.rb | 37 +++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'activesupport/test') diff --git a/activesupport/test/reloadable_test.rb b/activesupport/test/reloadable_test.rb index adac2fccec..fb1d61740d 100644 --- a/activesupport/test/reloadable_test.rb +++ b/activesupport/test/reloadable_test.rb @@ -27,6 +27,19 @@ module ReloadableTestSandbox end include Reloadable end + + class OnlySubclassesReloadable + include Reloadable::OnlySubclasses + end + class ASubclassOfOnlySubclassesReloadable < OnlySubclassesReloadable + end + + class AnOnlySubclassReloadableClassSubclassingAReloadableClass + include Reloadable::OnlySubclasses + end + + class ASubclassofAOnlySubclassReloadableClassWhichWasSubclassingAReloadableClass < AnOnlySubclassReloadableClassSubclassingAReloadableClass + end end class ReloadableTest < Test::Unit::TestCase @@ -43,9 +56,29 @@ class ReloadableTest < Test::Unit::TestCase assert_equal 10, ReloadableTestSandbox::AClassWhichDefinesItsOwnReloadable.reloadable? end + def test_only_subclass_reloadable + assert ! ReloadableTestSandbox::OnlySubclassesReloadable.reloadable? + assert ReloadableTestSandbox::ASubclassOfOnlySubclassesReloadable.reloadable? + end + + def test_inside_hierarchy_only_subclass_reloadable + assert ! ReloadableTestSandbox::AnOnlySubclassReloadableClassSubclassingAReloadableClass.reloadable? + assert ReloadableTestSandbox::ASubclassofAOnlySubclassReloadableClassWhichWasSubclassingAReloadableClass.reloadable? + end + def test_removable_classes - reloadables = %w(AReloadableClass AReloadableClassWithSubclasses AReloadableSubclass AClassWhichDefinesItsOwnReloadable) - non_reloadables = %w(ANonReloadableSubclass AModuleIncludingReloadable) + reloadables = %w( + AReloadableClass + AReloadableClassWithSubclasses + AReloadableSubclass + AClassWhichDefinesItsOwnReloadable + ASubclassOfOnlySubclassesReloadable + ) + non_reloadables = %w( + ANonReloadableSubclass + AModuleIncludingReloadable + OnlySubclassesReloadable + ) results = Reloadable.reloadable_classes reloadables.each do |name| -- cgit v1.2.3