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.
- data/README.md +30 -4
- data/Rakefile +5 -1
- data/lib/closure_tree/acts_as_tree.rb +1 -1
- data/lib/closure_tree/model.rb +63 -33
- data/lib/closure_tree/numeric_deterministic_ordering.rb +2 -2
- data/lib/closure_tree/support.rb +52 -16
- data/lib/closure_tree/version.rb +1 -1
- data/spec/db/schema.rb +4 -4
- data/spec/label_spec.rb +3 -3
- data/spec/parallel_spec.rb +12 -6
- data/spec/spec_helper.rb +27 -6
- data/spec/support/models.rb +27 -5
- data/spec/tag_examples.rb +421 -0
- data/spec/tag_fixture_examples.rb +136 -0
- data/spec/tag_spec.rb +4 -480
- data/spec/user_spec.rb +8 -8
- data/spec/uuid_tag_spec.rb +6 -0
- metadata +173 -172
- checksums.yaml +0 -15
- data/spec/hash_tree_spec.rb +0 -91
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=
|
data/spec/hash_tree_spec.rb
DELETED
@@ -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
|