2017-07-09 12:06:36 +00:00
|
|
|
# frozen_string_literal: true
|
2017-07-10 13:39:13 +00:00
|
|
|
|
2018-09-30 00:50:43 +00:00
|
|
|
require_relative "abstract_unit"
|
2016-08-06 16:03:25 +00:00
|
|
|
require "active_support/descendants_tracker"
|
|
|
|
require "active_support/dependencies"
|
2018-09-30 00:50:43 +00:00
|
|
|
require_relative "descendants_tracker_test_cases"
|
2011-03-13 15:52:34 +00:00
|
|
|
|
2012-01-06 01:12:46 +00:00
|
|
|
class DescendantsTrackerWithAutoloadingTest < ActiveSupport::TestCase
|
2011-03-13 15:52:34 +00:00
|
|
|
include DescendantsTrackerTestCases
|
|
|
|
|
2013-03-30 08:31:42 +00:00
|
|
|
def test_clear_with_autoloaded_parent_children_and_grandchildren
|
2011-03-13 15:52:34 +00:00
|
|
|
mark_as_autoloaded(*ALL) do
|
|
|
|
ActiveSupport::DescendantsTracker.clear
|
|
|
|
ALL.each do |k|
|
2018-01-25 23:16:57 +00:00
|
|
|
assert_empty ActiveSupport::DescendantsTracker.descendants(k)
|
2011-03-13 15:52:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-30 08:31:42 +00:00
|
|
|
def test_clear_with_autoloaded_children_and_grandchildren
|
2011-03-13 15:52:34 +00:00
|
|
|
mark_as_autoloaded Child1, Grandchild1, Grandchild2 do
|
|
|
|
ActiveSupport::DescendantsTracker.clear
|
2012-06-30 19:51:57 +00:00
|
|
|
assert_equal_sets [Child2], Parent.descendants
|
|
|
|
assert_equal_sets [], Child2.descendants
|
2011-03-13 15:52:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-30 08:31:42 +00:00
|
|
|
def test_clear_with_autoloaded_grandchildren
|
2011-03-13 15:52:34 +00:00
|
|
|
mark_as_autoloaded Grandchild1, Grandchild2 do
|
|
|
|
ActiveSupport::DescendantsTracker.clear
|
2012-06-30 19:51:57 +00:00
|
|
|
assert_equal_sets [Child1, Child2], Parent.descendants
|
|
|
|
assert_equal_sets [], Child1.descendants
|
|
|
|
assert_equal_sets [], Child2.descendants
|
2011-03-13 15:52:34 +00:00
|
|
|
end
|
|
|
|
end
|
2012-01-06 22:42:53 +00:00
|
|
|
end
|