aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2006-02-02 05:41:00 +0000
committerNicholas Seckar <nseckar@gmail.com>2006-02-02 05:41:00 +0000
commit1bce58b31289362d62863ad0600b924858a11e34 (patch)
treea99ebc764c8e91e04b490bd6145a5201341e50c3 /activesupport/test
parent4bb6f863b42814707c0df6d972c931c6925b3de8 (diff)
downloadrails-1bce58b31289362d62863ad0600b924858a11e34.tar.gz
rails-1bce58b31289362d62863ad0600b924858a11e34.tar.bz2
rails-1bce58b31289362d62863ad0600b924858a11e34.zip
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
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/reloadable_test.rb37
1 files changed, 35 insertions, 2 deletions
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|