closure_tree 4.0.1 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NzBiMzczYWMyY2IwMzMyMGFiMDE4ZWZiZGE5NDdmYjAwNWFlNmY5Ng==
5
- data.tar.gz: !binary |-
6
- NmNmMDYzNDcwZmM4MzBmNjA4ZTgxOGQxZjFmZGJlMTY5MGFjMTAyYg==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YWJmYWZkOWFlMDM2ZGQwZTlmMDZiYjAxOWYwZTJiMGI5NDQ2ZmNjNzliZWY2
10
- OTlhYWYxMGViMTY1ZGJmNGE1YzZlM2EwNDA5ZTE3YTZlMDgxOWY1MjA3YjM1
11
- NjkxOGIwMjk2NzVmYmIxOGNjY2ZlMDczOWYyNTdkMTYyZmVmMjQ=
12
- data.tar.gz: !binary |-
13
- Zjg1MmExYzAxZjc0MDIxOTE3YzczMTllYTc1NGVmZjQyM2JkNTQ5YWE1MDJl
14
- MTBlMzUyM2RmZTA3ZTg1MDUyNjY4YzgwMjljOWZmMTAyYWYwMmRjNzlkYThi
15
- MTYyMTNhZWQ2ZGQzZmY4YWU5OGQ3NDIyMzYxNjk4ZTliYTNjMjg=
@@ -1,91 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Tag do
4
-
5
- before :each do
6
- @b = Tag.find_or_create_by_path %w(a b)
7
- @a = @b.parent
8
- @b2 = Tag.find_or_create_by_path %w(a b2)
9
- @d1 = @b.find_or_create_by_path %w(c1 d1)
10
- @c1 = @d1.parent
11
- @d2 = @b.find_or_create_by_path %w(c2 d2)
12
- @c2 = @d2.parent
13
- @full_tree = {@a => {@b => {@c1 => {@d1 => {}}, @c2 => {@d2 => {}}}, @b2 => {}}}
14
- end
15
-
16
- context "#hash_tree" do
17
- it "returns {} for depth 0" do
18
- Tag.hash_tree(:limit_depth => 0).should == {}
19
- end
20
- it "limit_depth 1" do
21
- Tag.hash_tree(:limit_depth => 1).should == {@a => {}}
22
- end
23
- it "limit_depth 2" do
24
- Tag.hash_tree(:limit_depth => 2).should == {@a => {@b => {}, @b2 => {}}}
25
- end
26
- it "limit_depth 3" do
27
- Tag.hash_tree(:limit_depth => 3).should == {@a => {@b => {@c1 => {}, @c2 => {}}, @b2 => {}}}
28
- end
29
- it "limit_depth 4" do
30
- Tag.hash_tree(:limit_depth => 4).should == @full_tree
31
- end
32
- it "no limit holdum" do
33
- Tag.hash_tree.should == @full_tree
34
- end
35
- end
36
-
37
- def assert_no_dupes(scope)
38
- # the named scope is complicated enough that an incorrect join could result in unnecessarily
39
- # duplicated rows:
40
- a = scope.collect { |ea| ea.id }
41
- a.should == a.uniq
42
- end
43
-
44
- context "#hash_tree_scope" do
45
- it "no dupes for any depth" do
46
- (0..5).each do |ea|
47
- assert_no_dupes(Tag.hash_tree_scope(ea))
48
- end
49
- end
50
- it "no limit holdum" do
51
- assert_no_dupes(Tag.hash_tree_scope)
52
- end
53
- end
54
-
55
- context ".hash_tree_scope" do
56
- it "no dupes for any depth" do
57
- (0..5).each do |ea|
58
- assert_no_dupes(@a.hash_tree_scope(ea))
59
- end
60
- end
61
- it "no limit holdum" do
62
- assert_no_dupes(@a.hash_tree_scope)
63
- end
64
- end
65
-
66
- context ".hash_tree" do
67
- before :each do
68
- end
69
- it "returns {} for depth 0" do
70
- @b.hash_tree(:limit_depth => 0).should == {}
71
- end
72
- it "limit_depth 1" do
73
- @b.hash_tree(:limit_depth => 1).should == {@b => {}}
74
- end
75
- it "limit_depth 2" do
76
- @b.hash_tree(:limit_depth => 2).should == {@b => {@c1 => {}, @c2 => {}}}
77
- end
78
- it "limit_depth 3" do
79
- @b.hash_tree(:limit_depth => 3).should == {@b => {@c1 => {@d1 => {}}, @c2 => {@d2 => {}}}}
80
- end
81
- it "no limit holdum from subsubroot" do
82
- @c1.hash_tree.should == {@c1 => {@d1 => {}}}
83
- end
84
- it "no limit holdum from subroot" do
85
- @b.hash_tree.should == {@b => {@c1 => {@d1 => {}}, @c2 => {@d2 => {}}}}
86
- end
87
- it "no limit holdum from root" do
88
- @a.hash_tree.should == @full_tree
89
- end
90
- end
91
- end