aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/descendants_tracker_test_cases.rb
diff options
context:
space:
mode:
authorthedarkone <thedarkone2@gmail.com>2012-06-30 21:51:57 +0200
committerAaron Patterson <aaron.patterson@gmail.com>2012-10-18 12:08:01 -0700
commit9f84e60ac9d7bf07d6ae1bc94f3941f5b8f1a228 (patch)
tree57f412708b6ef0e20e1c030ff50f2abd4c0725ca /activesupport/test/descendants_tracker_test_cases.rb
parent4f106bbb2ccbcfb54865bdca786b9fb0ee669032 (diff)
downloadrails-9f84e60ac9d7bf07d6ae1bc94f3941f5b8f1a228.tar.gz
rails-9f84e60ac9d7bf07d6ae1bc94f3941f5b8f1a228.tar.bz2
rails-9f84e60ac9d7bf07d6ae1bc94f3941f5b8f1a228.zip
Make DescendantsTracker thread safe and optimize the #descendants method.
Diffstat (limited to 'activesupport/test/descendants_tracker_test_cases.rb')
-rw-r--r--activesupport/test/descendants_tracker_test_cases.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/activesupport/test/descendants_tracker_test_cases.rb b/activesupport/test/descendants_tracker_test_cases.rb
index 066ec8549b..8f8feb462c 100644
--- a/activesupport/test/descendants_tracker_test_cases.rb
+++ b/activesupport/test/descendants_tracker_test_cases.rb
@@ -1,3 +1,5 @@
+require 'set'
+
module DescendantsTrackerTestCases
class Parent
extend ActiveSupport::DescendantsTracker
@@ -18,15 +20,15 @@ module DescendantsTrackerTestCases
ALL = [Parent, Child1, Child2, Grandchild1, Grandchild2]
def test_descendants
- assert_equal [Child1, Grandchild1, Grandchild2, Child2], Parent.descendants
- assert_equal [Grandchild1, Grandchild2], Child1.descendants
- assert_equal [], Child2.descendants
+ assert_equal_sets [Child1, Grandchild1, Grandchild2, Child2], Parent.descendants
+ assert_equal_sets [Grandchild1, Grandchild2], Child1.descendants
+ assert_equal_sets [], Child2.descendants
end
def test_direct_descendants
- assert_equal [Child1, Child2], Parent.direct_descendants
- assert_equal [Grandchild1, Grandchild2], Child1.direct_descendants
- assert_equal [], Child2.direct_descendants
+ assert_equal_sets [Child1, Child2], Parent.direct_descendants
+ assert_equal_sets [Grandchild1, Grandchild2], Child1.direct_descendants
+ assert_equal_sets [], Child2.direct_descendants
end
def test_clear
@@ -40,6 +42,10 @@ module DescendantsTrackerTestCases
protected
+ def assert_equal_sets(expected, actual)
+ Set.new(expected) == Set.new(actual)
+ end
+
def mark_as_autoloaded(*klasses)
# If ActiveSupport::Dependencies is not loaded, forget about autoloading.
# This allows using AS::DescendantsTracker without AS::Dependencies.