lalala 4.0.0.dev.136 → 4.0.0.dev.141

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +0 -3
  3. data/lalala.gemspec +2 -6
  4. data/lib/lalala/version.rb +1 -1
  5. data/lib/lalala.rb +0 -1
  6. metadata +19 -53
  7. data/vendor/deps/closure_tree/.gitignore +0 -12
  8. data/vendor/deps/closure_tree/.travis.yml +0 -22
  9. data/vendor/deps/closure_tree/.yardopts +0 -3
  10. data/vendor/deps/closure_tree/Gemfile +0 -2
  11. data/vendor/deps/closure_tree/MIT-LICENSE +0 -19
  12. data/vendor/deps/closure_tree/README.md +0 -641
  13. data/vendor/deps/closure_tree/Rakefile +0 -26
  14. data/vendor/deps/closure_tree/ci/Gemfile.rails-3.0.x +0 -5
  15. data/vendor/deps/closure_tree/ci/Gemfile.rails-3.1.x +0 -4
  16. data/vendor/deps/closure_tree/ci/Gemfile.rails-3.2.x +0 -4
  17. data/vendor/deps/closure_tree/closure_tree.gemspec +0 -31
  18. data/vendor/deps/closure_tree/lib/closure_tree/acts_as_tree.rb +0 -55
  19. data/vendor/deps/closure_tree/lib/closure_tree/columns.rb +0 -123
  20. data/vendor/deps/closure_tree/lib/closure_tree/deterministic_ordering.rb +0 -49
  21. data/vendor/deps/closure_tree/lib/closure_tree/model.rb +0 -386
  22. data/vendor/deps/closure_tree/lib/closure_tree/numeric_deterministic_ordering.rb +0 -93
  23. data/vendor/deps/closure_tree/lib/closure_tree/version.rb +0 -3
  24. data/vendor/deps/closure_tree/lib/closure_tree/with_advisory_lock.rb +0 -18
  25. data/vendor/deps/closure_tree/lib/closure_tree.rb +0 -8
  26. data/vendor/deps/closure_tree/spec/cuisine_type_spec.rb +0 -30
  27. data/vendor/deps/closure_tree/spec/db/database.yml +0 -19
  28. data/vendor/deps/closure_tree/spec/db/schema.rb +0 -109
  29. data/vendor/deps/closure_tree/spec/fixtures/labels.yml +0 -55
  30. data/vendor/deps/closure_tree/spec/fixtures/tags.yml +0 -98
  31. data/vendor/deps/closure_tree/spec/hash_tree_spec.rb +0 -91
  32. data/vendor/deps/closure_tree/spec/label_spec.rb +0 -356
  33. data/vendor/deps/closure_tree/spec/namespace_type_spec.rb +0 -13
  34. data/vendor/deps/closure_tree/spec/parallel_prepend_sibling_spec.rb +0 -45
  35. data/vendor/deps/closure_tree/spec/parallel_spec.rb +0 -59
  36. data/vendor/deps/closure_tree/spec/spec_helper.rb +0 -57
  37. data/vendor/deps/closure_tree/spec/support/models.rb +0 -74
  38. data/vendor/deps/closure_tree/spec/tag_spec.rb +0 -469
  39. data/vendor/deps/closure_tree/spec/user_spec.rb +0 -136
  40. data/vendor/deps/closure_tree/tests.sh +0 -19
@@ -1,469 +0,0 @@
1
- require 'spec_helper'
2
-
3
- shared_examples_for "Tag (1)" do
4
-
5
- it "has correct accessible_attributes" do
6
- Tag.accessible_attributes.to_a.should =~ %w(parent name)
7
- end
8
-
9
- describe "empty db" do
10
-
11
- def nuke_db
12
- TagHierarchy.delete_all
13
- Tag.delete_all
14
- end
15
-
16
- before :each do
17
- nuke_db
18
- end
19
-
20
- context "empty db" do
21
- it "should return no entities" do
22
- Tag.roots.should be_empty
23
- Tag.leaves.should be_empty
24
- end
25
- end
26
-
27
- context "1 tag db" do
28
- it "should return the only entity as a root and leaf" do
29
- a = Tag.create!(:name => "a")
30
- Tag.roots.should == [a]
31
- Tag.leaves.should == [a]
32
- end
33
- end
34
-
35
- context "2 tag db" do
36
- before :each do
37
- @root = Tag.create!(:name => "root")
38
- @leaf = @root.add_child(Tag.create!(:name => "leaf"))
39
- end
40
- it "should return a simple root and leaf" do
41
- Tag.roots.should == [@root]
42
- Tag.leaves.should == [@leaf]
43
- end
44
- it "should return child_ids for root" do
45
- @root.child_ids.should == [@leaf.id]
46
- end
47
- it "should return an empty array for leaves" do
48
- @leaf.child_ids.should be_empty
49
- end
50
- end
51
-
52
- context "3 tag collection.create db" do
53
- before :each do
54
- @root = Tag.create! :name => "root"
55
- @mid = @root.children.create! :name => "mid"
56
- @leaf = @mid.children.create! :name => "leaf"
57
- DestroyedTag.delete_all
58
- end
59
-
60
- it "should create all tags" do
61
- Tag.all.should =~ [@root, @mid, @leaf]
62
- end
63
-
64
- it "should return a root and leaf without middle tag" do
65
- Tag.roots.should == [@root]
66
- Tag.leaves.should == [@leaf]
67
- end
68
-
69
- it "should delete leaves" do
70
- Tag.leaves.destroy_all
71
- Tag.roots.should == [@root] # untouched
72
- Tag.leaves.should == [@mid]
73
- end
74
-
75
- it "should delete everything if you delete the roots" do
76
- Tag.roots.destroy_all
77
- Tag.all.should be_empty
78
- Tag.roots.should be_empty
79
- Tag.leaves.should be_empty
80
- DestroyedTag.all.collect { |t| t.name }.should =~ %w{root mid leaf}
81
- end
82
- end
83
-
84
- context "3 tag explicit_create db" do
85
- before :each do
86
- @root = Tag.create!(:name => "root")
87
- @mid = @root.add_child(Tag.create!(:name => "mid"))
88
- @leaf = @mid.add_child(Tag.create!(:name => "leaf"))
89
- end
90
-
91
- it "should create all tags" do
92
- Tag.all.should =~ [@root, @mid, @leaf]
93
- end
94
-
95
- it "should return a root and leaf without middle tag" do
96
- Tag.roots.should == [@root]
97
- Tag.leaves.should == [@leaf]
98
- end
99
-
100
- it "should prevent parental loops from torso" do
101
- @mid.children << @root
102
- @root.valid?.should be_false
103
- @mid.reload.children.should == [@leaf]
104
- end
105
-
106
- it "should prevent parental loops from toes" do
107
- @leaf.children << @root
108
- @root.valid?.should be_false
109
- @leaf.reload.children.should be_empty
110
- end
111
-
112
- it "should support re-parenting" do
113
- @root.children << @leaf
114
- Tag.leaves.should == [@leaf, @mid]
115
- end
116
-
117
- it "cleans up hierarchy references for leaves" do
118
- @leaf.destroy
119
- TagHierarchy.find_all_by_ancestor_id(@leaf.id).should be_empty
120
- TagHierarchy.find_all_by_descendant_id(@leaf.id).should be_empty
121
- end
122
-
123
- it "cleans up hierarchy references" do
124
- @mid.destroy
125
- TagHierarchy.find_all_by_ancestor_id(@mid.id).should be_empty
126
- TagHierarchy.find_all_by_descendant_id(@mid.id).should be_empty
127
- @root.reload.should be_root
128
- root_hiers = @root.ancestor_hierarchies.to_a
129
- root_hiers.size.should == 1
130
- TagHierarchy.find_all_by_ancestor_id(@root.id).should == root_hiers
131
- TagHierarchy.find_all_by_descendant_id(@root.id).should == root_hiers
132
- end
133
- end
134
-
135
- it "performs as the readme says it does" do
136
- grandparent = Tag.create(:name => 'Grandparent')
137
- parent = grandparent.children.create(:name => 'Parent')
138
- child1 = Tag.create(:name => 'First Child', :parent => parent)
139
- child2 = Tag.new(:name => 'Second Child')
140
- parent.children << child2
141
- child3 = Tag.new(:name => 'Third Child')
142
- parent.add_child child3
143
- grandparent.self_and_descendants.collect(&:name).should ==
144
- ["Grandparent", "Parent", "First Child", "Second Child", "Third Child"]
145
- child1.ancestry_path.should ==
146
- ["Grandparent", "Parent", "First Child"]
147
- child3.ancestry_path.should ==
148
- ["Grandparent", "Parent", "Third Child"]
149
- d = Tag.find_or_create_by_path %w(a b c d)
150
- h = Tag.find_or_create_by_path %w(e f g h)
151
- e = h.root
152
- d.add_child(e) # "d.children << e" would work too, of course
153
- h.ancestry_path.should == %w(a b c d e f g h)
154
- end
155
-
156
- end
157
-
158
- context "paths" do
159
- before :each do
160
- @child = Tag.find_or_create_by_path(%w(grandparent parent child))
161
- @child.title = "Kid"
162
- @parent = @child.parent
163
- @parent.title = "Mom"
164
- @grandparent = @parent.parent
165
- @grandparent.title = "Nonnie"
166
- [@child, @parent, @grandparent].each { |ea| ea.save! }
167
- end
168
-
169
- it "should build ancestry path" do
170
- @child.ancestry_path.should == %w{grandparent parent child}
171
- @child.ancestry_path(:name).should == %w{grandparent parent child}
172
- @child.ancestry_path(:title).should == %w{Nonnie Mom Kid}
173
- end
174
-
175
- it "should find by path" do
176
- # class method:
177
- Tag.find_by_path(%w{grandparent parent child}).should == @child
178
- # instance method:
179
- @parent.find_by_path(%w{child}).should == @child
180
- @grandparent.find_by_path(%w{parent child}).should == @child
181
- @parent.find_by_path(%w{child larvae}).should be_nil
182
- end
183
-
184
- it "finds correctly rooted paths" do
185
- decoy = Tag.find_or_create_by_path %w(a b c d)
186
- b_d = Tag.find_or_create_by_path %w(b c d)
187
- Tag.find_by_path(%w(b c d)).should == b_d
188
- Tag.find_by_path(%w(c d)).should be_nil
189
- end
190
-
191
- it "find_by_path for 1 node" do
192
- b = Tag.find_or_create_by_path %w(a b)
193
- b2 = b.root.find_by_path(%w(b))
194
- b2.should == b
195
- end
196
-
197
- it "find_by_path for 2 nodes" do
198
- c = Tag.find_or_create_by_path %w(a b c)
199
- c.root.find_by_path(%w(b c)).should == c
200
- c.root.find_by_path(%w(a c)).should be_nil
201
- c.root.find_by_path(%w(c)).should be_nil
202
- end
203
-
204
- it "find_by_path for 3 nodes" do
205
- d = Tag.find_or_create_by_path %w(a b c d)
206
- d.root.find_by_path(%w(b c d)).should == d
207
- Tag.find_by_path(%w(a b c d)).should == d
208
- Tag.find_by_path(%w(d)).should be_nil
209
- end
210
-
211
- it "should return nil for missing nodes" do
212
- Tag.find_by_path(%w{missing}).should be_nil
213
- Tag.find_by_path(%w{grandparent missing}).should be_nil
214
- Tag.find_by_path(%w{grandparent parent missing}).should be_nil
215
- Tag.find_by_path(%w{grandparent parent missing child}).should be_nil
216
- end
217
-
218
- it "should find or create by path" do
219
- # class method:
220
- grandparent = Tag.find_or_create_by_path(%w{grandparent})
221
- grandparent.should == @grandparent
222
- child = Tag.find_or_create_by_path(%w{grandparent parent child})
223
- child.should == @child
224
- Tag.find_or_create_by_path(%w{events anniversary}).ancestry_path.should == %w{events anniversary}
225
- a = Tag.find_or_create_by_path(%w{a})
226
- a.ancestry_path.should == %w{a}
227
- # instance method:
228
- a.find_or_create_by_path(%w{b c}).ancestry_path.should == %w{a b c}
229
- end
230
- end
231
- end
232
-
233
- shared_examples_for "Tag (2)" do
234
- describe "Tag (2)" do
235
-
236
- fixtures :tags
237
-
238
- before :each do
239
- Tag.rebuild!
240
- DestroyedTag.delete_all
241
- end
242
-
243
- context "class injection" do
244
- it "should build hierarchy classname correctly" do
245
- Tag.hierarchy_class.to_s.should == "TagHierarchy"
246
- Tag.hierarchy_class_name.should == "TagHierarchy"
247
- Tag.short_hierarchy_class_name.should == "TagHierarchy"
248
- end
249
-
250
- it "should have a correct parent column name" do
251
- Tag.parent_column_name.should == "parent_id"
252
- end
253
- end
254
-
255
- context "roots" do
256
- it "should find global roots" do
257
- roots = Tag.roots.to_a
258
- roots.should be_member(tags(:people))
259
- roots.should be_member(tags(:events))
260
- roots.should_not be_member(tags(:child))
261
- tags(:people).root?.should be_true
262
- tags(:child).root?.should be_false
263
- end
264
-
265
- it "should find an instance root" do
266
- tags(:grandparent).root.should == tags(:grandparent)
267
- tags(:parent).root.should == tags(:grandparent)
268
- tags(:child).root.should == tags(:grandparent)
269
- end
270
- end
271
-
272
- context "leaves" do
273
- it "should assemble global leaves" do
274
- Tag.leaves.size.should > 0
275
- Tag.leaves.each { |t| t.children.should be_empty, "#{t.name} was returned by leaves but has children: #{t.children}" }
276
- Tag.leaves.each { |t| t.should be_leaf, "{t.name} was returned by leaves but was not a leaf" }
277
- end
278
-
279
- it "should assemble instance leaves" do
280
- tags(:grandparent).leaves.should == [tags(:child)]
281
- tags(:parent).leaves.should == [tags(:child)]
282
- tags(:child).leaves.should == [tags(:child)]
283
- end
284
- end
285
-
286
- context "adding children" do
287
- it "should work explicitly" do
288
- sb = Tag.create!(:name => "Santa Barbara")
289
- sb.leaf?.should_not be_nil
290
- tags(:california).add_child sb
291
- sb.leaf?.should_not be_nil
292
- validate_city_tag sb
293
- end
294
-
295
- it "should work implicitly through the collection" do
296
- eg = Tag.create!(:name => "El Granada")
297
- eg.leaf?.should_not be_nil
298
- tags(:california).children << eg
299
- eg.leaf?.should_not be_nil
300
- validate_city_tag eg
301
- end
302
-
303
- it "should fail to create ancestor loops" do
304
- child = tags(:child)
305
- parent = child.parent
306
- child.add_child(parent) # this should fail
307
- parent.valid?.should be_false
308
- child.reload.children.should be_empty
309
- parent.reload.children.should == [child]
310
- end
311
-
312
- it "should move non-leaves" do
313
- # This is what the fixture should encode:
314
- tags(:d2).ancestry_path.should == %w{a1 b2 c2 d2}
315
- tags(:b1).add_child(tags(:c2))
316
- tags(:b2).leaf?.should_not be_nil
317
- tags(:b1).children.include?(tags(:c2)).should be_true
318
- tags(:d2).reload.ancestry_path.should == %w{a1 b1 c2 d2}
319
- end
320
-
321
- it "should move leaves" do
322
- l = Tag.find_or_create_by_path(%w{leaftest branch1 leaf})
323
- b2 = Tag.find_or_create_by_path(%w{leaftest branch2})
324
- b2.children << l
325
- l.ancestry_path.should == %w{leaftest branch2 leaf}
326
- end
327
-
328
- it "should move roots" do
329
- l1 = Tag.find_or_create_by_path(%w{roottest1 branch1 leaf1})
330
- l2 = Tag.find_or_create_by_path(%w{roottest2 branch2 leaf2})
331
- l1.children << l2.root
332
- l1.reload.ancestry_path.should == %w{roottest1 branch1 leaf1}
333
- l2.reload.ancestry_path.should == %w{roottest1 branch1 leaf1 roottest2 branch2 leaf2}
334
- end
335
-
336
- it "should cascade delete all children" do
337
- b2 = tags(:b2)
338
- entities = b2.self_and_descendants.to_a
339
- names = b2.self_and_descendants.collect { |t| t.name }
340
- b2.destroy
341
- entities.each { |e| Tag.find_by_id(e.id).should be_nil }
342
- DestroyedTag.all.collect { |t| t.name }.should =~ names
343
- end
344
- end
345
-
346
- context "injected attributes" do
347
- it "should compute level correctly" do
348
- tags(:grandparent).level.should == 0
349
- tags(:parent).level.should == 1
350
- tags(:child).level.should == 2
351
- end
352
-
353
- it "should determine parent correctly" do
354
- tags(:grandparent).parent.should == nil
355
- tags(:parent).parent.should == tags(:grandparent)
356
- tags(:child).parent.should == tags(:parent)
357
- end
358
-
359
- it "should have a sane children collection" do
360
- tags(:grandparent).children.include? tags(:parent).should be_true
361
- tags(:parent).children.include? tags(:child).should be_true
362
- tags(:child).children.should be_empty
363
- end
364
-
365
- it "assembles siblings correctly" do
366
- tags(:b1).siblings.to_a.should =~ [tags(:b2)]
367
- tags(:a1).siblings.to_a.should =~ (Tag.roots.to_a - [tags(:a1)])
368
- tags(:a1).self_and_siblings.to_a.should =~ Tag.roots.to_a
369
-
370
- # must be ordered
371
- tags(:indoor).siblings.to_a.should == [tags(:home), tags(:museum), tags(:outdoor), tags(:united_states)]
372
- tags(:indoor).self_and_siblings.to_a.should == [tags(:home), tags(:indoor), tags(:museum), tags(:outdoor), tags(:united_states)]
373
- end
374
-
375
- it "assembles siblings before correctly" do
376
- tags(:home).siblings_before.to_a.should == []
377
- tags(:indoor).siblings_before.to_a.should == [tags(:home)]
378
- tags(:outdoor).siblings_before.to_a.should == [tags(:home), tags(:indoor), tags(:museum)]
379
- tags(:united_states).siblings_before.to_a.should == [tags(:home), tags(:indoor), tags(:museum), tags(:outdoor)]
380
- end
381
-
382
- it "assembles siblings after correctly" do
383
- tags(:indoor).siblings_after.to_a.should == [tags(:museum), tags(:outdoor), tags(:united_states)]
384
- tags(:outdoor).siblings_after.to_a.should == [tags(:united_states)]
385
- tags(:united_states).siblings_after.to_a.should == []
386
- end
387
-
388
- it "assembles ancestors" do
389
- tags(:child).ancestors.should == [tags(:parent), tags(:grandparent)]
390
- tags(:child).self_and_ancestors.should == [tags(:child), tags(:parent), tags(:grandparent)]
391
- end
392
-
393
- it "assembles descendants" do
394
- tags(:parent).descendants.should == [tags(:child)]
395
- tags(:parent).self_and_descendants.should == [tags(:parent), tags(:child)]
396
- tags(:grandparent).descendants.should == [tags(:parent), tags(:child)]
397
- tags(:grandparent).self_and_descendants.should == [tags(:grandparent), tags(:parent), tags(:child)]
398
- tags(:grandparent).self_and_descendants.collect { |t| t.name }.join(" > ").should == "grandparent > parent > child"
399
- end
400
- end
401
-
402
-
403
- def validate_city_tag city
404
- tags(:california).children.include?(city).should_not be_nil
405
- city.ancestors.should == [tags(:california), tags(:united_states), tags(:places)]
406
- city.self_and_ancestors.should == [city, tags(:california), tags(:united_states), tags(:places)]
407
- end
408
-
409
- end
410
- end
411
-
412
- describe Tag do
413
- it "should not include ActiveModel::ForbiddenAttributesProtection" do
414
- if defined?(ActiveModel::ForbiddenAttributesProtection)
415
- Tag.ancestors.should_not include(ActiveModel::ForbiddenAttributesProtection)
416
- end
417
- end
418
- it_behaves_like "Tag (1)"
419
- it_behaves_like "Tag (2)"
420
- end
421
-
422
- describe "Tag with AR whitelisted attributes enabled" do
423
- before(:all) do
424
- ActiveRecord::Base.attr_accessible(nil) # turn on whitelisted attributes
425
- ActiveRecord::Base.descendants.each { |ea| ea.reset_column_information }
426
- end
427
- it "should not include ActiveModel::ForbiddenAttributesProtection" do
428
- if defined?(ActiveModel::ForbiddenAttributesProtection)
429
- Tag.ancestors.should_not include(ActiveModel::ForbiddenAttributesProtection)
430
- end
431
- end
432
- it_behaves_like "Tag (1)"
433
- it_behaves_like "Tag (2)"
434
- end
435
-
436
- # This has to be the last one, because we include strong parameters into Tag
437
- describe "Tag with strong parameters" do
438
- before(:all) do
439
- require 'strong_parameters'
440
- class Tag
441
- include ActiveModel::ForbiddenAttributesProtection
442
- end
443
- end
444
- it_behaves_like "Tag (1)"
445
- it_behaves_like "Tag (2)"
446
- end
447
-
448
- describe "Tag with UUID" do
449
- before(:all) do
450
- # Change tables
451
- Tag.table_name = Tag.table_name.gsub('tags', 'tags_uuid')
452
- Tag.reset_column_information
453
- TagHierarchy.table_name = TagHierarchy.table_name.gsub('tag_hierarchies', 'tag_hierarchies_uuid')
454
- TagHierarchy.reset_column_information
455
-
456
- # We have to reset a few other caches
457
- Tag.closure_tree_options[:hierarchy_table_name] = 'tag_hierarchies_uuid'
458
- Tag.reflections.each do |key, ref|
459
- ref.instance_variable_set('@table_name', nil)
460
- ref.instance_variable_set('@quoted_table_name', nil)
461
- ref.options[:order].sub! 'tag_hierarchies', 'tag_hierarchies_uuid' if ref.options[:order]
462
- end
463
-
464
- # Add ID
465
- Tag.before_create { self.id = UUIDTools::UUID.random_create.to_s }
466
- end
467
-
468
- it_behaves_like "Tag (1)"
469
- end
@@ -1,136 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "empty db" do
4
-
5
- before :each do
6
- ReferralHierarchy.delete_all
7
- User.delete_all
8
- end
9
-
10
- context "empty db" do
11
- it "should return no entities" do
12
- User.roots.should be_empty
13
- User.leaves.should be_empty
14
- end
15
- end
16
-
17
- context "1 user db" do
18
- it "should return the only entity as a root and leaf" do
19
- a = User.create!(:email => "me@domain.com")
20
- User.roots.should == [a]
21
- User.leaves.should == [a]
22
- end
23
- end
24
-
25
- context "2 user db" do
26
- it "should return a simple root and leaf" do
27
- root = User.create!(:email => "first@t.co")
28
- leaf = root.children.create!(:email => "second@t.co")
29
- User.roots.should == [root]
30
- User.leaves.should == [leaf]
31
- end
32
- end
33
-
34
-
35
- context "3 User collection.create db" do
36
- before :each do
37
- @root = User.create! :email => "poppy@t.co"
38
- @mid = @root.children.create! :email => "matt@t.co"
39
- @leaf = @mid.children.create! :email => "james@t.co"
40
- @root_id = @root.id
41
- end
42
-
43
- it "should create all Users" do
44
- User.all.should =~ [@root, @mid, @leaf]
45
- end
46
-
47
- it "should return a root and leaf without middle User" do
48
- User.roots.should == [@root]
49
- User.leaves.should == [@leaf]
50
- end
51
-
52
- it "should delete leaves" do
53
- User.leaves.destroy_all
54
- User.roots.should == [@root] # untouched
55
- User.leaves.should == [@mid]
56
- end
57
-
58
- it "should delete roots and maintain hierarchies" do
59
- User.roots.destroy_all
60
- assert_mid_and_leaf_remain
61
- end
62
-
63
- it "should root all children" do
64
- @root.destroy
65
- assert_mid_and_leaf_remain
66
- end
67
-
68
- def assert_mid_and_leaf_remain
69
- ReferralHierarchy.find_all_by_ancestor_id(@root_id).should be_empty
70
- ReferralHierarchy.find_all_by_descendant_id(@root_id).should be_empty
71
- @mid.ancestry_path.should == %w{matt@t.co}
72
- @leaf.ancestry_path.should == %w{matt@t.co james@t.co}
73
- @mid.self_and_descendants.should =~ [@mid, @leaf]
74
- User.roots.should == [@mid]
75
- User.leaves.should == [@leaf]
76
- end
77
- end
78
-
79
- it "supports users with contracts" do
80
- u = User.find_or_create_by_path(%w(a@t.co b@t.co c@t.co))
81
- u.descendant_ids.should == []
82
- u.ancestor_ids.should == [u.parent.id, u.root.id]
83
- u.root.descendant_ids.should == [u.parent.id, u.id]
84
- u.root.ancestor_ids.should == []
85
- c1 = u.contracts.create!
86
- c2 = u.parent.contracts.create!
87
- u.root.indirect_contracts.to_a.should =~ [c1, c2]
88
- end
89
-
90
- it "supports << on shallow unsaved hierarchies" do
91
- a = User.new(:email => "a")
92
- b = User.new(:email => "b")
93
- a.children << b
94
- a.save
95
- User.roots.should == [a]
96
- User.leaves.should == [b]
97
- b.ancestry_path.should == %w(a b)
98
- end
99
-
100
- it "supports << on deep unsaved hierarchies" do
101
- a = User.new(:email => "a")
102
- b1 = User.new(:email => "b1")
103
- a.children << b1
104
- b2 = User.new(:email => "b2")
105
- a.children << b2
106
- c1 = User.new(:email => "c1")
107
- b2.children << c1
108
- c2 = User.new(:email => "c2")
109
- b2.children << c2
110
- d = User.new(:email => "d")
111
- c2.children << d
112
-
113
- a.save
114
- User.roots.should == [a]
115
- User.leaves.should =~ [b1, c1, d]
116
- d.ancestry_path.should == %w(a b2 c2 d)
117
- end
118
-
119
- it "supports siblings" do
120
- User.order_option.should be_nil
121
- a = User.create(:email => "a")
122
- b1 = a.children.create(:email => "b1")
123
- b2 = a.children.create(:email => "b2")
124
- b3 = a.children.create(:email => "b3")
125
- a.siblings.should be_empty
126
- b1.siblings.should =~ [b2, b3]
127
- end
128
-
129
- it "properly nullifies descendents" do
130
- c = User.find_or_create_by_path %w(a b c)
131
- b = c.parent
132
- c.root.destroy
133
- b.reload.should be_root
134
- b.child_ids.should == [c.id]
135
- end
136
- end
@@ -1,19 +0,0 @@
1
- #!/bin/sh -ex
2
- export BUNDLE_GEMFILE RMI DB
3
-
4
- for RMI in 1.8.7-p370 1.9.3-p327
5
- do
6
- rbenv local $RMI
7
- gem install bundler rake # < just to make sure
8
- rbenv rehash || true
9
-
10
- for BUNDLE_GEMFILE in ci/Gemfile.rails-3.0.x ci/Gemfile.rails-3.1.x ci/Gemfile.rails-3.2.x
11
- do
12
- bundle update --quiet
13
- for DB in sqlite mysql postgresql
14
- do
15
- echo $DB $BUNDLE_GEMFILE `ruby -v`
16
- bundle exec rake specs_with_db_ixes
17
- done
18
- done
19
- done