mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
203998c916
also: - makes test dependencies obvious - makes tests runnable from within subfolders
36 lines
1.1 KiB
Ruby
36 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "abstract_unit"
|
|
require "active_support/descendants_tracker"
|
|
require "active_support/dependencies"
|
|
require_relative "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
|