File: descendants_tracker_with_autoloading_test.rb

package info (click to toggle)
rails 2%3A4.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 21,580 kB
  • sloc: ruby: 172,699; sql: 43; yacc: 43; sh: 14; makefile: 12
file content (34 lines) | stat: -rw-r--r-- 1,118 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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 ActiveSupport::DescendantsTracker.descendants(k).empty?
      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