aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/descendants_tracker_with_autoloading_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/descendants_tracker_with_autoloading_test.rb')
-rw-r--r--activesupport/test/descendants_tracker_with_autoloading_test.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/activesupport/test/descendants_tracker_with_autoloading_test.rb b/activesupport/test/descendants_tracker_with_autoloading_test.rb
new file mode 100644
index 0000000000..d4fedb5a67
--- /dev/null
+++ b/activesupport/test/descendants_tracker_with_autoloading_test.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+require "abstract_unit"
+require "active_support/descendants_tracker"
+require "active_support/dependencies"
+require "descendants_tracker_test_cases"
+
+class DescendantsTrackerWithAutoloadingTest < ActiveSupport::TestCase
+ include DescendantsTrackerTestCases
+
+ def test_clear_with_autoloaded_parent_children_and_grandchildren
+ mark_as_autoloaded(*ALL) do
+ ActiveSupport::DescendantsTracker.clear
+ ALL.each do |k|
+ assert_empty ActiveSupport::DescendantsTracker.descendants(k)
+ end
+ end
+ end
+
+ def test_clear_with_autoloaded_children_and_grandchildren
+ mark_as_autoloaded Child1, Grandchild1, Grandchild2 do
+ ActiveSupport::DescendantsTracker.clear
+ assert_equal_sets [Child2], Parent.descendants
+ assert_equal_sets [], Child2.descendants
+ end
+ end
+
+ def test_clear_with_autoloaded_grandchildren
+ mark_as_autoloaded Grandchild1, Grandchild2 do
+ ActiveSupport::DescendantsTracker.clear
+ assert_equal_sets [Child1, Child2], Parent.descendants
+ assert_equal_sets [], Child1.descendants
+ assert_equal_sets [], Child2.descendants
+ end
+ end
+end