aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorEdgars Beigarts <edgars.beigarts@gmail.com>2017-12-14 12:37:51 +0200
committerEdgars Beigarts <edgars.beigarts@gmail.com>2019-03-26 12:11:37 +0200
commit7432c9226e67de1b9a334a097446ea8c12350dbe (patch)
treeed8539adcab91160ae8d8121b297bf5361561a2c /activesupport/test
parent15ca8ad0c1e94d11d0deb02535bc286e077d43ce (diff)
downloadrails-7432c9226e67de1b9a334a097446ea8c12350dbe.tar.gz
rails-7432c9226e67de1b9a334a097446ea8c12350dbe.tar.bz2
rails-7432c9226e67de1b9a334a097446ea8c12350dbe.zip
Use weak references in descendants tracker
It allows anonymous subclasses to be garbage collected.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/descendants_tracker_test_cases.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activesupport/test/descendants_tracker_test_cases.rb b/activesupport/test/descendants_tracker_test_cases.rb
index 2c94c3c56c..f8752688d2 100644
--- a/activesupport/test/descendants_tracker_test_cases.rb
+++ b/activesupport/test/descendants_tracker_test_cases.rb
@@ -27,6 +27,15 @@ module DescendantsTrackerTestCases
assert_equal_sets [], Child2.descendants
end
+ def test_descendants_with_garbage_collected_classes
+ 1.times do
+ child_klass = Class.new(Parent)
+ assert_equal_sets [Child1, Grandchild1, Grandchild2, Child2, child_klass], Parent.descendants
+ end
+ GC.start
+ assert_equal_sets [Child1, Grandchild1, Grandchild2, Child2], Parent.descendants
+ end
+
def test_direct_descendants
assert_equal_sets [Child1, Child2], Parent.direct_descendants
assert_equal_sets [Grandchild1, Grandchild2], Child1.direct_descendants