closure_tree 4.6.1 → 4.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MTllNmI0MTA3YzE0NTZkNTk2Yzg4NWNiZWE2MDljN2NhYjAwZDc5NQ==
5
- data.tar.gz: !binary |-
6
- MjVkZDM0ZmMyNGE1OTk3NWNkYzQ3NmMxYzAyMzI1OTViYjZiMzhjOQ==
2
+ SHA1:
3
+ metadata.gz: 9b06ce0d66fc54bc2e578c562b1ba81d645ae667
4
+ data.tar.gz: 2034f11a0b935071f164d059d8f061ba30f8ce69
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MjIwMzM4YjBlYTQ5N2M0ZGYzNWIwYzc3NGFiMGE5NzM3YTA0ZTI1MjlkMzhj
10
- NmZkODBkOGRlYTQwN2UzZGQ1NTU4ZDBjMzg4NmE3NjBkZDBmMjAzMDU1OWVk
11
- Y2RlZGVkYTJlYWMzYWNlMzBjYzA0NDkzNzQ2ZjA5MzE4ZGI1YWE=
12
- data.tar.gz: !binary |-
13
- MWJlNTQ0NDdiNDE4NWNlYjdmNTkyZmUyM2U2OTA5YjFlNGM5NjczY2VlNzg3
14
- OTk0NDQ3M2VjMGQ4MGI3N2MzOWEzZjAyNzZkOGMyYjFlNWU2YzUwNzAzZWI4
15
- ZWViMTQyZDM2NTFhNWQ3MWVhMGY4NDYzZDEwY2E0Y2NlMTJkNGQ=
6
+ metadata.gz: 9871e9018bc6260939462cdbd59e0d93016843cd3b7ae918d7d41d46dd038157337c32050d4049b44b52dc2a6286a903dd566b09d6a9f14afcd6d7b720de1393
7
+ data.tar.gz: 899d7917cb840077174a91f0d984c0904b89f0a72e946744ac33c8c298857032acc496ac20f4bbcc7a4b710c6b9e9df4611ae3a5fa4083d1dcd4bbbd5dfa05ef
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ### 4.6.2
4
+ * Pull in [106](https://github.com/mceachen/closure_tree/pull/106) which fixed a bug introduced
5
+ in 4.6.0 which broke if the numeric ordering column wasn't named 'sort_order'. Tests have been
6
+ added. Thanks for the fix, [Fission Xuiptz](https://github.com/fissionxuiptz)!
7
+
3
8
  ### 4.6.1
4
9
 
5
10
  * Address [issue 60](https://github.com/mceachen/closure_tree/issues/60) (use `.empty?` rather
@@ -117,12 +117,12 @@ module ClosureTree
117
117
  _ct_reorder_siblings(reorder_from_value)
118
118
 
119
119
  # The sort order should be correct now except for self and sibling, which may need to flip:
120
- sibling_is_after = self.reload.sort_order < sibling.reload.sort_order
120
+ sibling_is_after = self.reload.order_value < sibling.reload.order_value
121
121
  if add_after != sibling_is_after
122
122
  # We need to flip the sort orders:
123
- self_so, sib_so = self.sort_order, sibling.sort_order
124
- update_order_value(sib_so)
125
- sibling.update_order_value(self_so)
123
+ self_ov, sib_ov = self.order_value, sibling.order_value
124
+ update_order_value(sib_ov)
125
+ sibling.update_order_value(self_ov)
126
126
  end
127
127
 
128
128
  if prior_sibling_parent != self.parent
@@ -1,3 +1,3 @@
1
1
  module ClosureTree
2
- VERSION = Gem::Version.new('4.6.1') unless defined?(::ClosureTree::VERSION)
2
+ VERSION = Gem::Version.new('4.6.2') unless defined?(::ClosureTree::VERSION)
3
3
  end
@@ -65,7 +65,7 @@ end
65
65
 
66
66
  class Label < ActiveRecord::Base
67
67
  # make sure order doesn't matter
68
- acts_as_tree :order => :sort_order, # <- LOOK IT IS A SYMBOL OMG
68
+ acts_as_tree :order => :column_whereby_ordering_is_inferred, # <- symbol, and not "sort_order"
69
69
  :parent_column_name => "mother_id",
70
70
  :dependent => :destroy
71
71
 
@@ -70,7 +70,7 @@ ActiveRecord::Schema.define(:version => 0) do
70
70
  create_table "labels" do |t|
71
71
  t.string "name"
72
72
  t.string "type"
73
- t.integer "sort_order"
73
+ t.integer "column_whereby_ordering_is_inferred"
74
74
  t.integer "mother_id"
75
75
  end
76
76
 
@@ -11,7 +11,7 @@ def create_label_tree
11
11
  @c3 = @d3.parent
12
12
  @b2 = @c3.parent
13
13
  @a2 = @b2.parent
14
- Label.update_all("sort_order = id")
14
+ Label.update_all("#{Label._ct.order_column} = id")
15
15
  end
16
16
 
17
17
  def create_preorder_tree(suffix = "", &block)
@@ -83,10 +83,10 @@ describe Label do
83
83
  expected.shuffle.each do |ea|
84
84
  Label.create! do |l|
85
85
  l.name = "root #{ea}"
86
- l.sort_order = ea
86
+ l.order_value = ea
87
87
  end
88
88
  end
89
- Label.roots.collect { |ea| ea.sort_order }.should == expected
89
+ Label.roots.collect { |ea| ea.order_value }.should == expected
90
90
  end
91
91
  end
92
92
 
@@ -139,7 +139,7 @@ describe Label do
139
139
  before do
140
140
  classes = [Label, DateLabel, DirectoryLabel, EventLabel]
141
141
  create_preorder_tree do |ea|
142
- ea.type = classes[ea.sort_order % 4].to_s
142
+ ea.type = classes[ea.order_value % 4].to_s
143
143
  end
144
144
  end
145
145
  it "finds roots with specific classes" do
@@ -250,7 +250,7 @@ describe Label do
250
250
  end
251
251
 
252
252
  def name_and_order(enum)
253
- enum.map { |ea| [ea.name, ea.sort_order] }
253
+ enum.map { |ea| [ea.name, ea.order_value] }
254
254
  end
255
255
 
256
256
  def children_name_and_order
@@ -261,7 +261,7 @@ describe Label do
261
261
  name_and_order(Label.roots)
262
262
  end
263
263
 
264
- it 'sort_orders properly' do
264
+ it 'order_values properly' do
265
265
  children_name_and_order.should == [['a', 0], ['b', 1], ['c', 2], ['d', 3]]
266
266
  end
267
267
 
@@ -300,27 +300,27 @@ describe Label do
300
300
  a.append_sibling(b)
301
301
  a.self_and_siblings.collect(&:name).should == %w(a b)
302
302
  root.reload.children.collect(&:name).should == %w(a b)
303
- root.children.collect(&:sort_order).should == [0, 1]
303
+ root.children.collect(&:order_value).should == [0, 1]
304
304
 
305
305
  a.prepend_sibling(b)
306
306
  a.self_and_siblings.collect(&:name).should == %w(b a)
307
307
  root.reload.children.collect(&:name).should == %w(b a)
308
- root.children.collect(&:sort_order).should == [0, 1]
308
+ root.children.collect(&:order_value).should == [0, 1]
309
309
 
310
310
  a.append_sibling(c)
311
311
  a.self_and_siblings.collect(&:name).should == %w(b a c)
312
312
  root.reload.children.collect(&:name).should == %w(b a c)
313
- root.children.collect(&:sort_order).should == [0, 1, 2]
313
+ root.children.collect(&:order_value).should == [0, 1, 2]
314
314
 
315
315
  # We need to reload b because it was updated by a.append_sibling(c)
316
316
  b.reload.append_sibling(c)
317
317
  root.reload.children.collect(&:name).should == %w(b c a)
318
- root.children.collect(&:sort_order).should == [0, 1, 2]
318
+ root.children.collect(&:order_value).should == [0, 1, 2]
319
319
 
320
320
  # We need to reload a because it was updated by b.append_sibling(c)
321
321
  d = a.reload.append_sibling(Label.new(:name => "d"))
322
322
  d.self_and_siblings.collect(&:name).should == %w(b c a d)
323
- d.self_and_siblings.collect(&:sort_order).should == [0, 1, 2, 3]
323
+ d.self_and_siblings.collect(&:order_value).should == [0, 1, 2, 3]
324
324
  end
325
325
 
326
326
  # https://github.com/mceachen/closure_tree/issues/84
@@ -328,27 +328,27 @@ describe Label do
328
328
  root = Label.create(:name => "root")
329
329
  a = Label.create(:name => "a", :parent => root)
330
330
  b = Label.create(:name => "b", :parent => root)
331
- a.sort_order.should == 0
332
- b.sort_order.should == 1
331
+ a.order_value.should == 0
332
+ b.order_value.should == 1
333
333
  #c = Label.create(:name => "c")
334
334
 
335
- # should the sort_order for roots be set?
336
- root.sort_order.should_not be_nil
337
- root.sort_order.should == 0
335
+ # should the order_value for roots be set?
336
+ root.order_value.should_not be_nil
337
+ root.order_value.should == 0
338
338
 
339
- # sort_order should never be nil on a child.
340
- a.sort_order.should_not be_nil
341
- a.sort_order.should == 0
339
+ # order_value should never be nil on a child.
340
+ a.order_value.should_not be_nil
341
+ a.order_value.should == 0
342
342
  # Add a child to root at end of children.
343
343
  root.children << b
344
344
  b.parent.should == root
345
345
  a.self_and_siblings.collect(&:name).should == %w(a b)
346
346
  root.reload.children.collect(&:name).should == %w(a b)
347
- root.children.collect(&:sort_order).should == [0, 1]
347
+ root.children.collect(&:order_value).should == [0, 1]
348
348
  end
349
349
 
350
350
  context "#add_sibling" do
351
- it "should move a node before another node which has an uninitialized sort_order" do
351
+ it "should move a node before another node which has an uninitialized order_value" do
352
352
  f = Label.find_or_create_by_path %w(a b c d e fa)
353
353
  f0 = f.prepend_sibling(Label.new(:name => "fb")) # < not alpha sort, so name shouldn't matter
354
354
  f0.ancestry_path.should == %w(a b c d e fb)
@@ -374,42 +374,42 @@ describe Label do
374
374
  f3 = f2.prepend_sibling(Label.new(:name => "f3"))
375
375
  f4 = f2.append_sibling(Label.new(:name => "f4"))
376
376
  f1.add_sibling(f2)
377
- f1.self_and_siblings.collect(&:sort_order).should == [0, 1]
378
- f3.self_and_siblings.collect(&:sort_order).should == [0, 1]
377
+ f1.self_and_siblings.collect(&:order_value).should == [0, 1]
378
+ f3.self_and_siblings.collect(&:order_value).should == [0, 1]
379
379
  f1.self_and_siblings.collect(&:name).should == %w(f1 f2)
380
380
  f3.self_and_siblings.collect(&:name).should == %w(f3 f4)
381
381
  end
382
382
  end
383
383
 
384
- context "sort_order must be set" do
384
+ context "order_value must be set" do
385
385
 
386
386
  before do
387
387
  @root = Label.create(name: 'root')
388
388
  @a, @b, @c = %w(a b c).map { |n| @root.children.create(name: n) }
389
389
  end
390
390
 
391
- it 'should set sort_order on roots' do
392
- @root.sort_order.should == 0
391
+ it 'should set order_value on roots' do
392
+ @root.order_value.should == 0
393
393
  end
394
394
 
395
- it 'should set sort_order with siblings' do
396
- @a.sort_order.should == 0
397
- @b.sort_order.should == 1
398
- @c.sort_order.should == 2
395
+ it 'should set order_value with siblings' do
396
+ @a.order_value.should == 0
397
+ @b.order_value.should == 1
398
+ @c.order_value.should == 2
399
399
  end
400
400
 
401
- it 'should reset sort_order when a node is moved to another location' do
401
+ it 'should reset order_value when a node is moved to another location' do
402
402
  root2 = Label.create(name: 'root2')
403
403
  root2.add_child @b
404
- @a.sort_order.should == 0
405
- @b.sort_order.should == 0
406
- @c.reload.sort_order.should == 1
404
+ @a.order_value.should == 0
405
+ @b.order_value.should == 0
406
+ @c.reload.order_value.should == 1
407
407
  end
408
408
  end
409
409
 
410
410
  context "destructive reordering" do
411
411
  before :each do
412
- # to make sure sort_order isn't affected by additional nodes:
412
+ # to make sure order_value isn't affected by additional nodes:
413
413
  create_preorder_tree
414
414
  @root = Label.create(:name => 'root')
415
415
  @a = @root.children.create!(:name => 'a')
@@ -420,17 +420,17 @@ describe Label do
420
420
  it 'from head' do
421
421
  @a.destroy
422
422
  @root.reload.children.should == [@b, @c]
423
- @root.children.map { |ea| ea.sort_order }.should == [0, 1]
423
+ @root.children.map { |ea| ea.order_value }.should == [0, 1]
424
424
  end
425
425
  it 'from mid' do
426
426
  @b.destroy
427
427
  @root.reload.children.should == [@a, @c]
428
- @root.children.map { |ea| ea.sort_order }.should == [0, 1]
428
+ @root.children.map { |ea| ea.order_value }.should == [0, 1]
429
429
  end
430
430
  it 'from tail' do
431
431
  @c.destroy
432
432
  @root.reload.children.should == [@a, @b]
433
- @root.children.map { |ea| ea.sort_order }.should == [0, 1]
433
+ @root.children.map { |ea| ea.order_value }.should == [0, 1]
434
434
  end
435
435
  end
436
436
 
@@ -502,7 +502,7 @@ describe Label do
502
502
  # Let's create the second root by hand so we can explicitly set the sort order
503
503
  Label.create! do |l|
504
504
  l.name = "a1"
505
- l.sort_order = a.sort_order + 1
505
+ l.order_value = a.order_value + 1
506
506
  end
507
507
  create_preorder_tree('1')
508
508
  # Should be no change:
@@ -167,8 +167,8 @@ describe 'Concurrent creation', if: support_concurrency do
167
167
  @target = Label.find_or_create_by_path %w(root parent)
168
168
  run_workers(SiblingPrependerWorker)
169
169
  children = Label.roots
170
- uniq_sort_orders = children.collect { |ea| ea.sort_order }.uniq
171
- children.size.should == uniq_sort_orders.size
170
+ uniq_order_values = children.collect { |ea| ea.order_value }.uniq
171
+ children.size.should == uniq_order_values.size
172
172
 
173
173
  # The only non-root node should be "root":
174
174
  Label.all.select { |ea| ea.root? }.should == [@target.parent]
metadata CHANGED
@@ -1,167 +1,167 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: closure_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.1
4
+ version: 4.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew McEachen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-15 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: with_advisory_lock
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.0.9
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.0.9
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: yard
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.14.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.14.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec-instafail
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec-rails
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ! '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: uuidtools
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ! '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ! '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: database_cleaner
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ! '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ! '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: appraisal
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ! '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ! '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: timecop
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ! '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ! '>='
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  description: Easily and efficiently make your ActiveRecord model support hierarchies
@@ -171,10 +171,10 @@ executables: []
171
171
  extensions: []
172
172
  extra_rdoc_files: []
173
173
  files:
174
- - .gitignore
175
- - .rspec
176
- - .travis.yml
177
- - .yardopts
174
+ - ".gitignore"
175
+ - ".rspec"
176
+ - ".travis.yml"
177
+ - ".yardopts"
178
178
  - Appraisals
179
179
  - CHANGELOG.md
180
180
  - Gemfile
@@ -240,17 +240,17 @@ require_paths:
240
240
  - lib
241
241
  required_ruby_version: !ruby/object:Gem::Requirement
242
242
  requirements:
243
- - - ! '>='
243
+ - - ">="
244
244
  - !ruby/object:Gem::Version
245
245
  version: 1.9.3
246
246
  required_rubygems_version: !ruby/object:Gem::Requirement
247
247
  requirements:
248
- - - ! '>='
248
+ - - ">="
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0'
251
251
  requirements: []
252
252
  rubyforge_project:
253
- rubygems_version: 2.2.0
253
+ rubygems_version: 2.3.0
254
254
  signing_key:
255
255
  specification_version: 4
256
256
  summary: Easily and efficiently make your ActiveRecord model support hierarchies