From 7432c9226e67de1b9a334a097446ea8c12350dbe Mon Sep 17 00:00:00 2001
From: Edgars Beigarts <edgars.beigarts@gmail.com>
Date: Thu, 14 Dec 2017 12:37:51 +0200
Subject: Use weak references in descendants tracker

It allows anonymous subclasses to be garbage collected.
---
 activesupport/test/descendants_tracker_test_cases.rb | 9 +++++++++
 1 file changed, 9 insertions(+)

(limited to 'activesupport/test')

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
-- 
cgit v1.2.3