Skip to content
Newer
Older
100644 768 lines (685 sloc) 29.1 KB
8850dca Applied [82f6a33] Fixed it for Rails 3.2 and broke it for 2.x, change…
Stefan Henzen authored
1 require "environment"
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
2
3 class HasAncestryTreeTest < ActiveSupport::TestCase
5c90437 Merge remote-tracking branch 'ridsagrawal/master'
Stefan Henzen authored
4
1282d2e @stefankroes Initial commit
authored
5 def test_default_ancestry_column
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
6 AncestryTestDatabase.with_model do |model|
7 assert_equal :ancestry, model.ancestry_column
8 end
1282d2e @stefankroes Initial commit
authored
9 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
10
1282d2e @stefankroes Initial commit
authored
11 def test_non_default_ancestry_column
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
12 AncestryTestDatabase.with_model :ancestry_column => :alternative_ancestry do |model|
13 assert_equal :alternative_ancestry, model.ancestry_column
14 end
1282d2e @stefankroes Initial commit
authored
15 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
16
1282d2e @stefankroes Initial commit
authored
17 def test_setting_ancestry_column
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
18 AncestryTestDatabase.with_model do |model|
19 model.ancestry_column = :ancestors
20 assert_equal :ancestors, model.ancestry_column
21 model.ancestry_column = :ancestry
22 assert_equal :ancestry, model.ancestry_column
23 end
1282d2e @stefankroes Initial commit
authored
24 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
25
1282d2e @stefankroes Initial commit
authored
26 def test_default_orphan_strategy
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
27 AncestryTestDatabase.with_model do |model|
28 assert_equal :destroy, model.orphan_strategy
29 end
1282d2e @stefankroes Initial commit
authored
30 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
31
1282d2e @stefankroes Initial commit
authored
32 def test_non_default_orphan_strategy
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
33 AncestryTestDatabase.with_model :orphan_strategy => :rootify do |model|
34 assert_equal :rootify, model.orphan_strategy
35 end
1282d2e @stefankroes Initial commit
authored
36 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
37
1282d2e @stefankroes Initial commit
authored
38 def test_setting_orphan_strategy
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
39 AncestryTestDatabase.with_model do |model|
40 model.orphan_strategy = :rootify
41 assert_equal :rootify, model.orphan_strategy
42 model.orphan_strategy = :destroy
43 assert_equal :destroy, model.orphan_strategy
44 end
1282d2e @stefankroes Initial commit
authored
45 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
46
1282d2e @stefankroes Initial commit
authored
47 def test_setting_invalid_orphan_strategy
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
48 AncestryTestDatabase.with_model do |model|
49 assert_raise Ancestry::AncestryException do
50 model.orphan_strategy = :non_existent_orphan_strategy
51 end
1282d2e @stefankroes Initial commit
authored
52 end
e552e10 @cheerfulstoic Test to cover ticket: #44 (comment)
cheerfulstoic authored
53 end
54
55 def test_scoping_in_callbacks
56 AncestryTestDatabase.with_model do |model|
cd268b6 always discard scope when looking up root & parent
Stefan Henzen authored
57 $random_object = model.create
58
e552e10 @cheerfulstoic Test to cover ticket: #44 (comment)
cheerfulstoic authored
59 model.instance_eval do
60 after_create :after_create_callback
61 end
62 model.class_eval do
63 def after_create_callback
64 # We don't want to be in the #children scope here when creating the child
65 self.parent
cd268b6 always discard scope when looking up root & parent
Stefan Henzen authored
66 self.parent_id = $random_object.id if $random_object
67 self.root
e552e10 @cheerfulstoic Test to cover ticket: #44 (comment)
cheerfulstoic authored
68 end
69 end
70
71 parent = model.create
72 assert child = parent.children.create
73 end
1282d2e @stefankroes Initial commit
authored
74 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
75
1282d2e @stefankroes Initial commit
authored
76 def test_setup_test_nodes
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
77 AncestryTestDatabase.with_model :depth => 3, :width => 3 do |model, roots|
1282d2e @stefankroes Initial commit
authored
78 assert_equal Array, roots.class
79 assert_equal 3, roots.length
80 roots.each do |node, children|
81 assert_equal model, node.class
82 assert_equal Array, children.class
83 assert_equal 3, children.length
84 children.each do |node, children|
85 assert_equal model, node.class
86 assert_equal Array, children.class
87 assert_equal 3, children.length
88 children.each do |node, children|
89 assert_equal model, node.class
90 assert_equal Array, children.class
91 assert_equal 0, children.length
92 end
93 end
94 end
95 end
96 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
97
1282d2e @stefankroes Initial commit
authored
98 def test_tree_navigation
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
99 AncestryTestDatabase.with_model :depth => 3, :width => 3 do |model, roots|
100 roots.each do |lvl0_node, lvl0_children|
1282d2e @stefankroes Initial commit
authored
101 # Ancestors assertions
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
102 assert_equal [], lvl0_node.ancestor_ids
103 assert_equal [], lvl0_node.ancestors
104 assert_equal [lvl0_node.id], lvl0_node.path_ids
105 assert_equal [lvl0_node], lvl0_node.path
106 assert_equal 0, lvl0_node.depth
1282d2e @stefankroes Initial commit
authored
107 # Parent assertions
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
108 assert_equal nil, lvl0_node.parent_id
109 assert_equal nil, lvl0_node.parent
1282d2e @stefankroes Initial commit
authored
110 # Root assertions
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
111 assert_equal lvl0_node.id, lvl0_node.root_id
112 assert_equal lvl0_node, lvl0_node.root
113 assert lvl0_node.is_root?
1282d2e @stefankroes Initial commit
authored
114 # Children assertions
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
115 assert_equal lvl0_children.map(&:first).map(&:id), lvl0_node.child_ids
116 assert_equal lvl0_children.map(&:first), lvl0_node.children
117 assert lvl0_node.has_children?
118 assert !lvl0_node.is_childless?
1282d2e @stefankroes Initial commit
authored
119 # Siblings assertions
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
120 assert_equal roots.map(&:first).map(&:id), lvl0_node.sibling_ids
121 assert_equal roots.map(&:first), lvl0_node.siblings
122 assert lvl0_node.has_siblings?
123 assert !lvl0_node.is_only_child?
1282d2e @stefankroes Initial commit
authored
124 # Descendants assertions
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
125 descendants = model.all.find_all do |node|
126 node.ancestor_ids.include? lvl0_node.id
1282d2e @stefankroes Initial commit
authored
127 end
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
128 assert_equal descendants.map(&:id), lvl0_node.descendant_ids
129 assert_equal descendants, lvl0_node.descendants
130 assert_equal [lvl0_node] + descendants, lvl0_node.subtree
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
131
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
132 lvl0_children.each do |lvl1_node, lvl1_children|
1282d2e @stefankroes Initial commit
authored
133 # Ancestors assertions
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
134 assert_equal [lvl0_node.id], lvl1_node.ancestor_ids
135 assert_equal [lvl0_node], lvl1_node.ancestors
136 assert_equal [lvl0_node.id, lvl1_node.id], lvl1_node.path_ids
137 assert_equal [lvl0_node, lvl1_node], lvl1_node.path
138 assert_equal 1, lvl1_node.depth
1282d2e @stefankroes Initial commit
authored
139 # Parent assertions
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
140 assert_equal lvl0_node.id, lvl1_node.parent_id
141 assert_equal lvl0_node, lvl1_node.parent
1282d2e @stefankroes Initial commit
authored
142 # Root assertions
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
143 assert_equal lvl0_node.id, lvl1_node.root_id
144 assert_equal lvl0_node, lvl1_node.root
145 assert !lvl1_node.is_root?
1282d2e @stefankroes Initial commit
authored
146 # Children assertions
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
147 assert_equal lvl1_children.map(&:first).map(&:id), lvl1_node.child_ids
148 assert_equal lvl1_children.map(&:first), lvl1_node.children
149 assert lvl1_node.has_children?
150 assert !lvl1_node.is_childless?
1282d2e @stefankroes Initial commit
authored
151 # Siblings assertions
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
152 assert_equal lvl0_children.map(&:first).map(&:id), lvl1_node.sibling_ids
153 assert_equal lvl0_children.map(&:first), lvl1_node.siblings
154 assert lvl1_node.has_siblings?
155 assert !lvl1_node.is_only_child?
1282d2e @stefankroes Initial commit
authored
156 # Descendants assertions
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
157 descendants = model.all.find_all do |node|
158 node.ancestor_ids.include? lvl1_node.id
159 end
160 assert_equal descendants.map(&:id), lvl1_node.descendant_ids
161 assert_equal descendants, lvl1_node.descendants
162 assert_equal [lvl1_node] + descendants, lvl1_node.subtree
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
163
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
164 lvl1_children.each do |lvl2_node, lvl2_children|
165 # Ancestors assertions
166 assert_equal [lvl0_node.id, lvl1_node.id], lvl2_node.ancestor_ids
167 assert_equal [lvl0_node, lvl1_node], lvl2_node.ancestors
168 assert_equal [lvl0_node.id, lvl1_node.id, lvl2_node.id], lvl2_node.path_ids
169 assert_equal [lvl0_node, lvl1_node, lvl2_node], lvl2_node.path
170 assert_equal 2, lvl2_node.depth
171 # Parent assertions
172 assert_equal lvl1_node.id, lvl2_node.parent_id
173 assert_equal lvl1_node, lvl2_node.parent
174 # Root assertions
175 assert_equal lvl0_node.id, lvl2_node.root_id
176 assert_equal lvl0_node, lvl2_node.root
177 assert !lvl2_node.is_root?
178 # Children assertions
179 assert_equal [], lvl2_node.child_ids
180 assert_equal [], lvl2_node.children
181 assert !lvl2_node.has_children?
182 assert lvl2_node.is_childless?
183 # Siblings assertions
184 assert_equal lvl1_children.map(&:first).map(&:id), lvl2_node.sibling_ids
185 assert_equal lvl1_children.map(&:first), lvl2_node.siblings
186 assert lvl2_node.has_siblings?
187 assert !lvl2_node.is_only_child?
188 # Descendants assertions
189 descendants = model.all.find_all do |node|
190 node.ancestor_ids.include? lvl2_node.id
191 end
192 assert_equal descendants.map(&:id), lvl2_node.descendant_ids
193 assert_equal descendants, lvl2_node.descendants
194 assert_equal [lvl2_node] + descendants, lvl2_node.subtree
1282d2e @stefankroes Initial commit
authored
195 end
196 end
197 end
198 end
199 end
200
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
201 def test_scopes
202 AncestryTestDatabase.with_model :depth => 3, :width => 3 do |model, roots|
203 # Roots assertion
204 assert_equal roots.map(&:first), model.roots.all
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
205
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
206 model.all.each do |test_node|
207 # Assertions for ancestors_of named scope
208 assert_equal test_node.ancestors.all, model.ancestors_of(test_node).all
209 assert_equal test_node.ancestors.all, model.ancestors_of(test_node.id).all
210 # Assertions for children_of named scope
211 assert_equal test_node.children.all, model.children_of(test_node).all
212 assert_equal test_node.children.all, model.children_of(test_node.id).all
213 # Assertions for descendants_of named scope
214 assert_equal test_node.descendants.all, model.descendants_of(test_node).all
215 assert_equal test_node.descendants.all, model.descendants_of(test_node.id).all
216 # Assertions for subtree_of named scope
217 assert_equal test_node.subtree.all, model.subtree_of(test_node).all
218 assert_equal test_node.subtree.all, model.subtree_of(test_node.id).all
219 # Assertions for siblings_of named scope
220 assert_equal test_node.siblings.all, model.siblings_of(test_node).all
221 assert_equal test_node.siblings.all, model.siblings_of(test_node.id).all
222 end
1282d2e @stefankroes Initial commit
authored
223 end
224 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
225
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
226 def test_ancestry_column_validation
227 AncestryTestDatabase.with_model do |model|
228 node = model.create
229 ['3', '10/2', '1/4/30', nil].each do |value|
230 node.send :write_attribute, model.ancestry_column, value
231 node.valid?; assert node.errors[model.ancestry_column].blank?
232 end
233 ['1/3/', '/2/3', 'a', 'a/b', '-34', '/54'].each do |value|
234 node.send :write_attribute, model.ancestry_column, value
235 node.valid?; assert !node.errors[model.ancestry_column].blank?
236 end
1282d2e @stefankroes Initial commit
authored
237 end
238 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
239
1282d2e @stefankroes Initial commit
authored
240 def test_descendants_move_with_node
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
241 AncestryTestDatabase.with_model :depth => 3, :width => 3 do |model, roots|
242 root1, root2, root3 = roots.map(&:first)
243 assert_no_difference 'root1.descendants.size' do
244 assert_difference 'root2.descendants.size', root1.subtree.size do
245 root1.parent = root2
246 root1.save!
247 end
1282d2e @stefankroes Initial commit
authored
248 end
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
249 assert_no_difference 'root2.descendants.size' do
250 assert_difference 'root3.descendants.size', root2.subtree.size do
251 root2.parent = root3
252 root2.save!
253 end
1282d2e @stefankroes Initial commit
authored
254 end
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
255 assert_no_difference 'root1.descendants.size' do
256 assert_difference 'root2.descendants.size', -root1.subtree.size do
257 assert_difference 'root3.descendants.size', -root1.subtree.size do
258 root1.parent = nil
259 root1.save!
260 end
1282d2e @stefankroes Initial commit
authored
261 end
262 end
263 end
264 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
265
1282d2e @stefankroes Initial commit
authored
266 def test_orphan_rootify_strategy
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
267 AncestryTestDatabase.with_model :depth => 3, :width => 3 do |model, roots|
268 model.orphan_strategy = :rootify
269 root = roots.first.first
270 children = root.children.all
271 root.destroy
272 children.each do |child|
273 child.reload
274 assert child.is_root?
275 assert_equal 3, child.children.size
276 end
1282d2e @stefankroes Initial commit
authored
277 end
278 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
279
1282d2e @stefankroes Initial commit
authored
280 def test_orphan_destroy_strategy
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
281 AncestryTestDatabase.with_model :depth => 3, :width => 3 do |model, roots|
282 model.orphan_strategy = :destroy
283 root = roots.first.first
284 assert_difference 'model.count', -root.subtree.size do
285 root.destroy
286 end
287 node = model.roots.first.children.first
288 assert_difference 'model.count', -node.subtree.size do
289 node.destroy
290 end
1282d2e @stefankroes Initial commit
authored
291 end
292 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
293
1282d2e @stefankroes Initial commit
authored
294 def test_orphan_restrict_strategy
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
295 AncestryTestDatabase.with_model :depth => 3, :width => 3 do |model, roots|
296 model.orphan_strategy = :restrict
297 root = roots.first.first
298 assert_raise Ancestry::AncestryException do
299 root.destroy
300 end
301 assert_nothing_raised Ancestry::AncestryException do
302 root.children.first.children.first.destroy
303 end
1282d2e @stefankroes Initial commit
authored
304 end
305 end
5c90437 Merge remote-tracking branch 'ridsagrawal/master'
Stefan Henzen authored
306
307 def test_orphan_adopt_strategy
308 AncestryTestDatabase.with_model do |model|
309 model.orphan_strategy = :adopt # set the orphan strategy as paerntify
310 n1 = model.create! #create a root node
311 n2 = model.create!(:parent => n1) #create child with parent=root
312 n3 = model.create!(:parent => n2) #create child with parent=n2, depth = 2
313 n4 = model.create!(:parent => n2) #create child with parent=n2, depth = 2
314 n5 = model.create!(:parent => n4) #create child with parent=n4, depth = 3
315 n2.destroy # delete a node with desecendants
316 assert_equal(model.find(n3.id).parent,n1, "orphan's not parentified" )
317 assert_equal(model.find(n5.id).ancestor_ids,[n1.id,n4.id], "ancestry integrity not maintained")
318 n1.destroy # delete a root node with desecendants
319 assert_equal(model.find(n3.id).parent_id,nil," Children of the deleted root not rootfied")
320 assert_equal(model.find(n5.id).ancestor_ids,[n4.id],"ancestry integrity not maintained")
321 end
322 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
323
1282d2e @stefankroes Initial commit
authored
324 def test_integrity_checking
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
325 AncestryTestDatabase.with_model :width => 3, :depth => 3 do |model, roots|
326 # Check that there are no errors on a valid tree
327 assert_nothing_raised do
328 model.check_ancestry_integrity!
329 end
34a13a9 @stefankroes Fixes for 1.2.1
authored
330 assert_equal 0, model.check_ancestry_integrity!(:report => :list).size
1282d2e @stefankroes Initial commit
authored
331 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
332
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
333 AncestryTestDatabase.with_model :width => 3, :depth => 3 do |model, roots|
334 # Check detection of invalid format for ancestry column
335 roots.first.first.update_attribute model.ancestry_column, 'invalid_ancestry'
336 assert_raise Ancestry::AncestryIntegrityException do
337 model.check_ancestry_integrity!
338 end
34a13a9 @stefankroes Fixes for 1.2.1
authored
339 assert_equal 1, model.check_ancestry_integrity!(:report => :list).size
1282d2e @stefankroes Initial commit
authored
340 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
341
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
342 AncestryTestDatabase.with_model :width => 3, :depth => 3 do |model, roots|
343 # Check detection of non-existent ancestor
344 roots.first.first.update_attribute model.ancestry_column, 35
345 assert_raise Ancestry::AncestryIntegrityException do
346 model.check_ancestry_integrity!
347 end
34a13a9 @stefankroes Fixes for 1.2.1
authored
348 assert_equal 1, model.check_ancestry_integrity!(:report => :list).size
1282d2e @stefankroes Initial commit
authored
349 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
350
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
351 AncestryTestDatabase.with_model :width => 3, :depth => 3 do |model, roots|
352 # Check detection of cyclic ancestry
353 node = roots.first.first
354 node.update_attribute model.ancestry_column, node.id
355 assert_raise Ancestry::AncestryIntegrityException do
356 model.check_ancestry_integrity!
357 end
34a13a9 @stefankroes Fixes for 1.2.1
authored
358 assert_equal 1, model.check_ancestry_integrity!(:report => :list).size
1282d2e @stefankroes Initial commit
authored
359 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
360
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
361 AncestryTestDatabase.with_model do |model|
362 # Check detection of conflicting parent id
363 model.destroy_all
364 model.create!(model.ancestry_column => model.create!(model.ancestry_column => model.create!(model.ancestry_column => nil).id).id)
365 assert_raise Ancestry::AncestryIntegrityException do
366 model.check_ancestry_integrity!
367 end
34a13a9 @stefankroes Fixes for 1.2.1
authored
368 assert_equal 1, model.check_ancestry_integrity!(:report => :list).size
1282d2e @stefankroes Initial commit
authored
369 end
370 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
371
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
372 def assert_integrity_restoration model
1282d2e @stefankroes Initial commit
authored
373 assert_raise Ancestry::AncestryIntegrityException do
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
374 model.check_ancestry_integrity!
1282d2e @stefankroes Initial commit
authored
375 end
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
376 model.restore_ancestry_integrity!
1282d2e @stefankroes Initial commit
authored
377 assert_nothing_raised do
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
378 model.check_ancestry_integrity!
1282d2e @stefankroes Initial commit
authored
379 end
770f2e3 Fix bug in restore_ancestry_integrity!, added test to verify we didn'…
Arthur Holstvoogd authored
380 assert model.all.any? {|node| node.ancestry.present? }, "Expected some nodes not to be roots"
381 assert_equal model.count, model.roots.collect {|node| node.descendants.count + 1 }.sum
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
382 end
383
1282d2e @stefankroes Initial commit
authored
384 def test_integrity_restoration
770f2e3 Fix bug in restore_ancestry_integrity!, added test to verify we didn'…
Arthur Holstvoogd authored
385 width, depth = 3, 3
1282d2e @stefankroes Initial commit
authored
386 # Check that integrity is restored for invalid format for ancestry column
770f2e3 Fix bug in restore_ancestry_integrity!, added test to verify we didn'…
Arthur Holstvoogd authored
387 AncestryTestDatabase.with_model :width => width, :depth => depth do |model, roots|
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
388 roots.first.first.update_attribute model.ancestry_column, 'invalid_ancestry'
389 assert_integrity_restoration model
390 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
391
1282d2e @stefankroes Initial commit
authored
392 # Check that integrity is restored for non-existent ancestor
770f2e3 Fix bug in restore_ancestry_integrity!, added test to verify we didn'…
Arthur Holstvoogd authored
393 AncestryTestDatabase.with_model :width => width, :depth => depth do |model, roots|
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
394 roots.first.first.update_attribute model.ancestry_column, 35
395 assert_integrity_restoration model
396 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
397
1282d2e @stefankroes Initial commit
authored
398 # Check that integrity is restored for cyclic ancestry
770f2e3 Fix bug in restore_ancestry_integrity!, added test to verify we didn'…
Arthur Holstvoogd authored
399 AncestryTestDatabase.with_model :width => width, :depth => depth do |model, roots|
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
400 node = roots.first.first
401 node.update_attribute model.ancestry_column, node.id
402 assert_integrity_restoration model
403 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
404
1282d2e @stefankroes Initial commit
authored
405 # Check that integrity is restored for conflicting parent id
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
406 AncestryTestDatabase.with_model do |model|
407 model.destroy_all
408 model.create!(model.ancestry_column => model.create!(model.ancestry_column => model.create!(model.ancestry_column => nil).id).id)
409 assert_integrity_restoration model
410 end
1282d2e @stefankroes Initial commit
authored
411 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
412
1282d2e @stefankroes Initial commit
authored
413 def test_arrangement
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
414 AncestryTestDatabase.with_model :depth => 3, :width => 3 do |model, roots|
415 id_sorter = Proc.new do |a, b|; a.id <=> b.id; end
416 arranged_nodes = model.arrange
417 assert_equal 3, arranged_nodes.size
418 arranged_nodes.each do |node, children|
1282d2e @stefankroes Initial commit
authored
419 assert_equal node.children.sort(&id_sorter), children.keys.sort(&id_sorter)
420 children.each do |node, children|
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
421 assert_equal node.children.sort(&id_sorter), children.keys.sort(&id_sorter)
422 children.each do |node, children|
423 assert_equal 0, children.size
424 end
1282d2e @stefankroes Initial commit
authored
425 end
426 end
427 end
428 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
429
22a1984 - Added some tests for node creation through scopes
Stefan Kroes authored
430 def test_node_creation_though_scope
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
431 AncestryTestDatabase.with_model do |model|
432 node = model.create!
433 child = node.children.create
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
434 assert_equal node, child.parent
435
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
436 other_child = child.siblings.create!
437 assert_equal node, other_child.parent
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
438
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
439 grandchild = model.children_of(child).new
440 grandchild.save
441 assert_equal child, grandchild.parent
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
442
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
443 other_grandchild = model.siblings_of(grandchild).new
444 other_grandchild.save!
445 assert_equal child, other_grandchild.parent
446 end
22a1984 - Added some tests for node creation through scopes
Stefan Kroes authored
447 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
448
488e752 @stefankroes Added validation to detect cycles in record ancestry
authored
449 def test_validate_ancestry_exclude_self
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
450 AncestryTestDatabase.with_model do |model|
451 parent = model.create!
452 child = parent.children.create!
453 assert_raise ActiveRecord::RecordInvalid do
454 parent.update_attributes! :parent => child
455 end
488e752 @stefankroes Added validation to detect cycles in record ancestry
authored
456 end
457 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
458
df705c3 @stefankroes Version 1.1.0 done!
authored
459 def test_depth_caching
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
460 AncestryTestDatabase.with_model :depth => 3, :width => 3, :cache_depth => true, :depth_cache_column => :depth_cache do |model, roots|
461 roots.each do |lvl0_node, lvl0_children|
462 assert_equal 0, lvl0_node.depth_cache
463 lvl0_children.each do |lvl1_node, lvl1_children|
464 assert_equal 1, lvl1_node.depth_cache
465 lvl1_children.each do |lvl2_node, lvl2_children|
466 assert_equal 2, lvl2_node.depth_cache
467 end
df705c3 @stefankroes Version 1.1.0 done!
authored
468 end
469 end
470 end
471 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
472
df705c3 @stefankroes Version 1.1.0 done!
authored
473 def test_depth_scopes
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
474 AncestryTestDatabase.with_model :depth => 4, :width => 2, :cache_depth => true do |model, roots|
475 model.before_depth(2).all? { |node| assert node.depth < 2 }
476 model.to_depth(2).all? { |node| assert node.depth <= 2 }
477 model.at_depth(2).all? { |node| assert node.depth == 2 }
478 model.from_depth(2).all? { |node| assert node.depth >= 2 }
479 model.after_depth(2).all? { |node| assert node.depth > 2 }
480 end
df705c3 @stefankroes Version 1.1.0 done!
authored
481 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
482
df705c3 @stefankroes Version 1.1.0 done!
authored
483 def test_depth_scopes_unavailable
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
484 AncestryTestDatabase.with_model do |model|
485 assert_raise Ancestry::AncestryException do
486 model.before_depth(1)
487 end
488 assert_raise Ancestry::AncestryException do
489 model.to_depth(1)
490 end
491 assert_raise Ancestry::AncestryException do
492 model.at_depth(1)
493 end
494 assert_raise Ancestry::AncestryException do
495 model.from_depth(1)
496 end
497 assert_raise Ancestry::AncestryException do
498 model.after_depth(1)
499 end
df705c3 @stefankroes Version 1.1.0 done!
authored
500 end
501 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
502
ecea76f @stefankroes Version 1.2.0
authored
503 def test_invalid_has_ancestry_options
df705c3 @stefankroes Version 1.1.0 done!
authored
504 assert_raise Ancestry::AncestryException do
ecea76f @stefankroes Version 1.2.0
authored
505 Class.new(ActiveRecord::Base).has_ancestry :this_option_doesnt_exist => 42
df705c3 @stefankroes Version 1.1.0 done!
authored
506 end
507 assert_raise Ancestry::AncestryException do
ecea76f @stefankroes Version 1.2.0
authored
508 Class.new(ActiveRecord::Base).has_ancestry :not_a_hash
df705c3 @stefankroes Version 1.1.0 done!
authored
509 end
510 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
511
df705c3 @stefankroes Version 1.1.0 done!
authored
512 def test_build_ancestry_from_parent_ids
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
513 AncestryTestDatabase.with_model :skip_ancestry => true, :extra_columns => {:parent_id => :integer} do |model|
514 [model.create!].each do |parent|
515 (Array.new(5) { model.create! :parent_id => parent.id }).each do |parent|
516 (Array.new(5) { model.create! :parent_id => parent.id }).each do |parent|
517 (Array.new(5) { model.create! :parent_id => parent.id })
518 end
df705c3 @stefankroes Version 1.1.0 done!
authored
519 end
520 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
521
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
522 # Assert all nodes where created
34a13a9 @stefankroes Fixes for 1.2.1
authored
523 assert_equal (0..3).map { |n| 5 ** n }.sum, model.count
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
524
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
525 model.has_ancestry
526 model.build_ancestry_from_parent_ids!
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
527
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
528 # Assert ancestry integrity
529 assert_nothing_raised do
530 model.check_ancestry_integrity!
531 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
532
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
533 roots = model.roots.all
534 # Assert single root node
535 assert_equal 1, roots.size
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
536
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
537 # Assert it has 5 children
538 roots.each do |parent|
34a13a9 @stefankroes Fixes for 1.2.1
authored
539 assert_equal 5, parent.children.count
df705c3 @stefankroes Version 1.1.0 done!
authored
540 parent.children.each do |parent|
34a13a9 @stefankroes Fixes for 1.2.1
authored
541 assert_equal 5, parent.children.count
df705c3 @stefankroes Version 1.1.0 done!
authored
542 parent.children.each do |parent|
34a13a9 @stefankroes Fixes for 1.2.1
authored
543 assert_equal 5, parent.children.count
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
544 parent.children.each do |parent|
34a13a9 @stefankroes Fixes for 1.2.1
authored
545 assert_equal 0, parent.children.count
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
546 end
df705c3 @stefankroes Version 1.1.0 done!
authored
547 end
548 end
549 end
550 end
551 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
552
df705c3 @stefankroes Version 1.1.0 done!
authored
553 def test_rebuild_depth_cache
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
554 AncestryTestDatabase.with_model :depth => 3, :width => 3, :cache_depth => true, :depth_cache_column => :depth_cache do |model, roots|
555 model.connection.execute("update test_nodes set depth_cache = null;")
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
556
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
557 # Assert cache was emptied correctly
558 model.all.each do |test_node|
559 assert_equal nil, test_node.depth_cache
560 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
561
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
562 # Rebuild cache
563 model.rebuild_depth_cache!
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
564
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
565 # Assert cache was rebuild correctly
566 model.all.each do |test_node|
567 assert_equal test_node.depth, test_node.depth_cache
568 end
df705c3 @stefankroes Version 1.1.0 done!
authored
569 end
570 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
571
df705c3 @stefankroes Version 1.1.0 done!
authored
572 def test_exception_when_rebuilding_depth_cache_for_model_without_depth_caching
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
573 AncestryTestDatabase.with_model do |model|
574 assert_raise Ancestry::AncestryException do
575 model.rebuild_depth_cache!
576 end
df705c3 @stefankroes Version 1.1.0 done!
authored
577 end
578 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
579
df705c3 @stefankroes Version 1.1.0 done!
authored
580 def test_descendants_with_depth_constraints
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
581 AncestryTestDatabase.with_model :depth => 4, :width => 4, :cache_depth => true do |model, roots|
582 assert_equal 4, model.roots.first.descendants(:before_depth => 2).count
583 assert_equal 20, model.roots.first.descendants(:to_depth => 2).count
584 assert_equal 16, model.roots.first.descendants(:at_depth => 2).count
585 assert_equal 80, model.roots.first.descendants(:from_depth => 2).count
586 assert_equal 64, model.roots.first.descendants(:after_depth => 2).count
587 end
df705c3 @stefankroes Version 1.1.0 done!
authored
588 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
589
df705c3 @stefankroes Version 1.1.0 done!
authored
590 def test_subtree_with_depth_constraints
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
591 AncestryTestDatabase.with_model :depth => 4, :width => 4, :cache_depth => true do |model, roots|
592 assert_equal 5, model.roots.first.subtree(:before_depth => 2).count
593 assert_equal 21, model.roots.first.subtree(:to_depth => 2).count
594 assert_equal 16, model.roots.first.subtree(:at_depth => 2).count
595 assert_equal 80, model.roots.first.subtree(:from_depth => 2).count
596 assert_equal 64, model.roots.first.subtree(:after_depth => 2).count
597 end
df705c3 @stefankroes Version 1.1.0 done!
authored
598 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
599
600
df705c3 @stefankroes Version 1.1.0 done!
authored
601 def test_ancestors_with_depth_constraints
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
602 AncestryTestDatabase.with_model :cache_depth => true do |model|
603 node1 = model.create!
604 node2 = node1.children.create!
605 node3 = node2.children.create!
606 node4 = node3.children.create!
607 node5 = node4.children.create!
608 leaf = node5.children.create!
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
609
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
610 assert_equal [node1, node2, node3], leaf.ancestors(:before_depth => -2)
611 assert_equal [node1, node2, node3, node4], leaf.ancestors(:to_depth => -2)
612 assert_equal [node4], leaf.ancestors(:at_depth => -2)
613 assert_equal [node4, node5], leaf.ancestors(:from_depth => -2)
614 assert_equal [node5], leaf.ancestors(:after_depth => -2)
615 end
df705c3 @stefankroes Version 1.1.0 done!
authored
616 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
617
df705c3 @stefankroes Version 1.1.0 done!
authored
618 def test_path_with_depth_constraints
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
619 AncestryTestDatabase.with_model :cache_depth => true do |model|
620 node1 = model.create!
621 node2 = node1.children.create!
622 node3 = node2.children.create!
623 node4 = node3.children.create!
624 node5 = node4.children.create!
625 leaf = node5.children.create!
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
626
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
627 assert_equal [node1, node2, node3], leaf.path(:before_depth => -2)
628 assert_equal [node1, node2, node3, node4], leaf.path(:to_depth => -2)
629 assert_equal [node4], leaf.path(:at_depth => -2)
630 assert_equal [node4, node5, leaf], leaf.path(:from_depth => -2)
631 assert_equal [node5, leaf], leaf.path(:after_depth => -2)
632 end
df705c3 @stefankroes Version 1.1.0 done!
authored
633 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
634
df705c3 @stefankroes Version 1.1.0 done!
authored
635 def test_exception_on_unknown_depth_column
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
636 AncestryTestDatabase.with_model :cache_depth => true do |model|
637 assert_raise Ancestry::AncestryException do
638 model.create!.subtree(:this_is_not_a_valid_depth_option => 42)
639 end
df705c3 @stefankroes Version 1.1.0 done!
authored
640 end
641 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
642
e3ea26a @stefankroes - Version 1.1.2 (2009-10-29)
authored
643 def test_sti_support
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
644 AncestryTestDatabase.with_model :extra_columns => {:type => :string} do |model|
645 subclass1 = Object.const_set 'Subclass1', Class.new(model)
646 (class << subclass1; self; end).send :define_method, :model_name do; Struct.new(:human, :underscore).new 'Subclass1', 'subclass1'; end
647 subclass2 = Object.const_set 'Subclass2', Class.new(model)
648 (class << subclass2; self; end).send :define_method, :model_name do; Struct.new(:human, :underscore).new 'Subclass1', 'subclass1'; end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
649
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
650 node1 = subclass1.create!
651 node2 = subclass2.create! :parent => node1
652 node3 = subclass1.create! :parent => node2
653 node4 = subclass2.create! :parent => node3
654 node5 = subclass1.create! :parent => node4
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
655
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
656 model.all.each do |node|
657 assert [subclass1, subclass2].include?(node.class)
658 end
659
660 assert_equal [node2.id, node3.id, node4.id, node5.id], node1.descendants.map(&:id)
661 assert_equal [node1.id, node2.id, node3.id, node4.id, node5.id], node1.subtree.map(&:id)
662 assert_equal [node1.id, node2.id, node3.id, node4.id], node5.ancestors.map(&:id)
663 assert_equal [node1.id, node2.id, node3.id, node4.id, node5.id], node5.path.map(&:id)
664 end
e3ea26a @stefankroes - Version 1.1.2 (2009-10-29)
authored
665 end
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
666
ecea76f @stefankroes Version 1.2.0
authored
667 def test_arrange_order_option
f1955bb @stefankroes Changed test suite to run independently of Rails application
authored
668 AncestryTestDatabase.with_model :width => 3, :depth => 3 do |model, roots|
669 descending_nodes_lvl0 = model.arrange :order => 'id desc'
670 ascending_nodes_lvl0 = model.arrange :order => 'id asc'
d8cd386 Automatically determine primary key column type, and cast to integer …
Rolf Timmermans authored
671
ecea76f @stefankroes Version 1.2.0
authored
672 descending_nodes_lvl0.keys.zip(ascending_nodes_lvl0.keys.reverse).each do |descending_node, ascending_node|
673 assert_equal descending_node, ascending_node
674 descending_nodes_lvl1 = descending_nodes_lvl0[descending_node]
675 ascending_nodes_lvl1 = ascending_nodes_lvl0[ascending_node]
676 descending_nodes_lvl1.keys.zip(ascending_nodes_lvl1.keys.reverse).each do |descending_node, ascending_node|
677 assert_equal descending_node, ascending_node
678 descending_nodes_lvl2 = descending_nodes_lvl1[descending_node]
679 ascending_nodes_lvl2 = ascending_nodes_lvl1[ascending_node]
680 descending_nodes_lvl2.keys.zip(ascending_nodes_lvl2.keys.reverse).each do |descending_node, ascending_node|
681 assert_equal descending_node, ascending_node
682 descending_nodes_lvl3 = descending_nodes_lvl2[descending_node]
683 ascending_nodes_lvl3 = ascending_nodes_lvl2[ascending_node]
684 descending_nodes_lvl3.keys.zip(ascending_nodes_lvl3.keys.reverse).each do |descending_node, ascending_node|
685 assert_equal descending_node, ascending_node
686 end
687 end
688 end
689 end
690 end
691 end
5614a3b @kueda Added class method to sort nodes by ancestry.
kueda authored
692
693 def test_sort_by_ancestry
694 AncestryTestDatabase.with_model do |model|
695 n1 = model.create!
696 n2 = model.create!(:parent => n1)
697 n3 = model.create!(:parent => n2)
698 n4 = model.create!(:parent => n2)
699 n5 = model.create!(:parent => n1)
700
701 arranged = model.sort_by_ancestry(model.all.sort_by(&:id).reverse)
702 assert_equal [n1, n2, n4, n3, n5].map(&:id), arranged.map(&:id)
703 end
704 end
eeadeef @gstokkink ancestry should skip default scopes for some of the node update methods.
gstokkink authored
705
706 def test_node_excluded_by_default_scope_should_still_move_with_parent
707 AncestryTestDatabase.with_model(
708 :width => 3, :depth => 3, :extra_columns => {:deleted_at => :datetime},
709 :default_scope_params => {:conditions => {:deleted_at => nil}}
710 ) do |model, roots|
711 grandparent = model.roots.all[0]
712 new_grandparent = model.roots.all[1]
713 parent = grandparent.children.first
714 child = parent.children.first
715
716 child.update_attributes :deleted_at => Time.now
717 parent.update_attributes :parent => new_grandparent
718 child.update_attributes :deleted_at => nil
719
720 assert child.reload.ancestors.include? new_grandparent
721 end
722 end
723
724 def test_node_excluded_by_default_scope_should_be_destroyed_with_parent
725 AncestryTestDatabase.with_model(
726 :width => 1, :depth => 2, :extra_columns => {:deleted_at => :datetime},
727 :default_scope_params => {:conditions => {:deleted_at => nil}},
728 :orphan_strategy => :destroy
729 ) do |model, roots|
730 parent = model.roots.first
731 child = parent.children.first
732
733 child.update_attributes :deleted_at => Time.now
734 parent.destroy
735 child.update_attributes :deleted_at => nil
736
737 assert model.count.zero?
738 end
739 end
740
741 def test_node_excluded_by_default_scope_should_be_rootified
742 AncestryTestDatabase.with_model(
743 :width => 1, :depth => 2, :extra_columns => {:deleted_at => :datetime},
744 :default_scope_params => {:conditions => {:deleted_at => nil}},
745 :orphan_strategy => :rootify
746 ) do |model, roots|
747 parent = model.roots.first
748 child = parent.children.first
749
750 child.update_attributes :deleted_at => Time.now
751 parent.destroy
752 child.update_attributes :deleted_at => nil
753
754 assert child.reload.is_root?
755 end
756 end
8850dca Applied [82f6a33] Fixed it for Rails 3.2 and broke it for 2.x, change…
Stefan Henzen authored
757
758 def test_arrangement_nesting
759 AncestryTestDatabase.with_model :extra_columns => {:name => :string} do |model|
760 model.send :default_scope, model.order('name')
761
762 model.create!(:name => 'Linux').children.create! :name => 'Debian'
763
764 assert_equal 1, model.arrange.count
765 end
766 end
1282d2e @stefankroes Initial commit
authored
767 end
Something went wrong with that request. Please try again.