closure_tree 3.4.1 → 3.4.2
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.
- data/README.md +5 -0
- data/lib/closure_tree/acts_as_tree.rb +2 -0
- data/lib/closure_tree/version.rb +1 -1
- data/spec/fixtures/labels.yml +4 -0
- data/spec/label_spec.rb +20 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -324,6 +324,11 @@ Closure tree is [tested under every combination](http://travis-ci.org/#!/mceache
|
|
324
324
|
## Change log
|
325
325
|
|
326
326
|
|
327
|
+
### 3.4.2
|
328
|
+
|
329
|
+
* Fixed [issue 18](https://github.com/mceachen/closure_tree/issues/18), which affected
|
330
|
+
append_node/prepend_node ordering when the first node didn't have an explicit order_by value
|
331
|
+
|
327
332
|
### 3.4.1
|
328
333
|
|
329
334
|
* Reverted .gemspec mistake that changed add_development_dependency to add_runtime_dependency
|
@@ -474,6 +474,8 @@ module ClosureTree
|
|
474
474
|
|
475
475
|
def add_sibling(sibling_node, use_update_all = true, add_after = true)
|
476
476
|
fail "can't add self as sibling" if self == sibling_node
|
477
|
+
# issue 18: we need to set the order_value explicitly so subsequent orders will work.
|
478
|
+
update_attribute(:order_value, 0) if self.order_value.nil?
|
477
479
|
sibling_node.order_value = self.order_value.to_i + (add_after ? 1 : -1)
|
478
480
|
# We need to incr the before_siblings to make room for sibling_node:
|
479
481
|
if use_update_all
|
data/lib/closure_tree/version.rb
CHANGED
data/spec/fixtures/labels.yml
CHANGED
data/spec/label_spec.rb
CHANGED
@@ -130,6 +130,26 @@ describe Label do
|
|
130
130
|
labels(:c2).self_and_siblings.to_a.should == [labels(:b1), labels(:c2), labels(:b2)]
|
131
131
|
end
|
132
132
|
|
133
|
+
it "should move a node before another node which has an uninitialized sort_order" do
|
134
|
+
labels(:f3).ancestry_path.should == %w{f3}
|
135
|
+
labels(:e2).children << labels(:f3)
|
136
|
+
labels(:f3).reload.ancestry_path.should == %w{a1 b2 c2 d2 e2 f3}
|
137
|
+
labels(:f3).self_and_siblings.to_a.should == [labels(:f3)]
|
138
|
+
labels(:f3).prepend_sibling labels(:f4)
|
139
|
+
labels(:f3).siblings_before.to_a.should == [labels(:f4)]
|
140
|
+
labels(:f3).self_and_siblings.to_a.should == [labels(:f4), labels(:f3)]
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should move a node after another node which has an uninitialized sort_order" do
|
144
|
+
labels(:f3).ancestry_path.should == %w{f3}
|
145
|
+
labels(:e2).children << labels(:f3)
|
146
|
+
labels(:f3).reload.ancestry_path.should == %w{a1 b2 c2 d2 e2 f3}
|
147
|
+
labels(:f3).self_and_siblings.to_a.should == [labels(:f3)]
|
148
|
+
labels(:f3).append_sibling labels(:f4)
|
149
|
+
labels(:f3).siblings_after.to_a.should == [labels(:f4)]
|
150
|
+
labels(:f3).self_and_siblings.to_a.should == [labels(:f3), labels(:f4)]
|
151
|
+
end
|
152
|
+
|
133
153
|
it "should move a node after another node" do
|
134
154
|
labels(:c2).ancestry_path.should == %w{a1 b2 c2}
|
135
155
|
labels(:b2).append_sibling(labels(:c2), false)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: closure_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -192,7 +192,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
192
|
version: '0'
|
193
193
|
segments:
|
194
194
|
- 0
|
195
|
-
hash:
|
195
|
+
hash: 2623137531718887180
|
196
196
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
197
197
|
none: false
|
198
198
|
requirements:
|
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
201
|
version: '0'
|
202
202
|
segments:
|
203
203
|
- 0
|
204
|
-
hash:
|
204
|
+
hash: 2623137531718887180
|
205
205
|
requirements: []
|
206
206
|
rubyforge_project:
|
207
207
|
rubygems_version: 1.8.23
|