From 76e4e2fa468593c42623472055d329dfeb577c49 Mon Sep 17 00:00:00 2001 From: Rolf Timmermans Date: Sun, 13 Mar 2011 16:52:34 +0100 Subject: Refactored AS::DescendantsTracker test cases so they can be tested without AS::Dependencies. --- .../descendants_tracker_with_autoloading_test.rb | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 activesupport/test/descendants_tracker_with_autoloading_test.rb (limited to 'activesupport/test/descendants_tracker_with_autoloading_test.rb') 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..ae18a56f44 --- /dev/null +++ b/activesupport/test/descendants_tracker_with_autoloading_test.rb @@ -0,0 +1,35 @@ +require 'abstract_unit' +require 'test/unit' +require 'active_support/descendants_tracker' +require 'active_support/dependencies' +require 'descendants_tracker_test_cases' + +class DescendantsTrackerWithAutoloadingTest < Test::Unit::TestCase + include DescendantsTrackerTestCases + + def test_clear_with_autoloaded_parent_children_and_granchildren + mark_as_autoloaded(*ALL) do + ActiveSupport::DescendantsTracker.clear + ALL.each do |k| + assert ActiveSupport::DescendantsTracker.descendants(k).empty? + end + end + end + + def test_clear_with_autoloaded_children_and_granchildren + mark_as_autoloaded Child1, Grandchild1, Grandchild2 do + ActiveSupport::DescendantsTracker.clear + assert_equal [Child2], Parent.descendants + assert_equal [], Child2.descendants + end + end + + def test_clear_with_autoloaded_granchildren + mark_as_autoloaded Grandchild1, Grandchild2 do + ActiveSupport::DescendantsTracker.clear + assert_equal [Child1, Child2], Parent.descendants + assert_equal [], Child1.descendants + assert_equal [], Child2.descendants + end + end +end \ No newline at end of file -- cgit v1.2.3