dm-is-nested_set 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -358,7 +358,7 @@ module DataMapper
358
358
  def right_sibling
359
359
  self_and_siblings.find{|v| v.lft == rgt+1}
360
360
  end
361
-
361
+
362
362
  private
363
363
  def detach
364
364
  offset = self.lft - self.rgt - 1
@@ -1,7 +1,7 @@
1
1
  module DataMapper
2
2
  module Is
3
3
  module NestedSet
4
- VERSION = "0.9.3"
4
+ VERSION = "0.9.4"
5
5
  end
6
6
  end
7
- end
7
+ end
@@ -1,10 +1,10 @@
1
1
  require 'rubygems'
2
2
  require 'pathname'
3
3
 
4
- gem 'dm-core', '=0.9.3'
4
+ gem 'dm-core', '=0.9.4'
5
5
  require 'dm-core'
6
6
 
7
- gem 'dm-adjust', '=0.9.3'
7
+ gem 'dm-adjust', '=0.9.4'
8
8
  require 'dm-adjust'
9
9
 
10
10
  require Pathname(__FILE__).dirname.expand_path / 'dm-is-nested_set' / 'is' / 'nested_set.rb'
@@ -25,9 +25,9 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
25
25
 
26
26
  def pos; [lft,rgt] end # convenience method only for speccing.
27
27
  end
28
-
28
+
29
29
  class CustomCategory < Category
30
-
30
+
31
31
  end
32
32
 
33
33
  def setup
@@ -92,13 +92,13 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
92
92
  end
93
93
  end
94
94
  end
95
-
95
+
96
96
  describe 'Class#root and #root' do
97
97
  it 'should return the toplevel node' do
98
98
  Category.root.name.should == "Electronics"
99
99
  end
100
100
  end
101
-
101
+
102
102
  describe 'Class#leaves and #leaves' do
103
103
  it 'should return all nodes without descendants' do
104
104
  repository(:default) do
@@ -110,7 +110,7 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
110
110
  end
111
111
  end
112
112
  end
113
-
113
+
114
114
  describe '#ancestor, #ancestors and #self_and_ancestors' do
115
115
  it 'should return ancestors in an array' do
116
116
  repository(:default) do |repos|
@@ -123,7 +123,7 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
123
123
  end
124
124
  end
125
125
  end
126
-
126
+
127
127
  describe '#children' do
128
128
  it 'should return children of node' do
129
129
  repository(:default) do |repos|
@@ -138,7 +138,7 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
138
138
  end
139
139
  end
140
140
 
141
- Category.get(1).children
141
+ Category.get(1).children
142
142
 
143
143
  describe '#descendants and #self_and_descendants' do
144
144
  it 'should return all subnodes of node' do
@@ -170,7 +170,7 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
170
170
  end
171
171
 
172
172
  describe '#move' do
173
-
173
+
174
174
  # Outset:
175
175
  # id | lft| rgt| title
176
176
  #========================================
@@ -184,118 +184,118 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
184
184
  # 8 | 12 | 13 | - Flash
185
185
  # 9 | 15 | 16 | - CD Players
186
186
  # 10 | 17 | 18 | - 2 Way Radios
187
-
187
+
188
188
  it 'should move items correctly with :higher / :highest / :lower / :lowest' do
189
189
  repository(:default) do |repos|
190
-
190
+
191
191
  Category.get(4).pos.should == [5,6]
192
-
192
+
193
193
  Category.get(4).move(:above => Category.get(3))
194
194
  Category.get(4).pos.should == [3,4]
195
-
195
+
196
196
  Category.get(4).move(:higher).should == false
197
197
  Category.get(4).pos.should == [3,4]
198
198
  Category.get(3).pos.should == [5,6]
199
199
  Category.get(4).right_sibling.should == Category.get(3)
200
-
200
+
201
201
  Category.get(4).move(:lower)
202
202
  Category.get(4).pos.should == [5,6]
203
203
  Category.get(4).left_sibling.should == Category.get(3)
204
204
  Category.get(4).right_sibling.should == Category.get(5)
205
-
205
+
206
206
  Category.get(4).move(:highest)
207
207
  Category.get(4).pos.should == [3,4]
208
208
  Category.get(4).move(:higher).should == false
209
-
209
+
210
210
  Category.get(4).move(:lowest)
211
211
  Category.get(4).pos.should == [7,8]
212
212
  Category.get(4).left_sibling.should == Category.get(5)
213
-
213
+
214
214
  Category.get(4).move(:higher) # should reset the tree to how it was
215
-
215
+
216
216
  end
217
217
  end
218
-
218
+
219
219
  it 'should move items correctly with :indent / :outdent' do
220
220
  repository(:default) do |repos|
221
-
221
+
222
222
  mp3_players = Category.get(7)
223
-
223
+
224
224
  portable_electronics = Category.get(6)
225
225
  televisions = Category.get(2)
226
-
226
+
227
227
  mp3_players.pos.should == [11,14]
228
228
  #mp3_players.descendants.length.should == 1
229
-
229
+
230
230
  # The category is at the top of its parent, should not be able to indent.
231
231
  mp3_players.move(:indent).should == false
232
-
232
+
233
233
  mp3_players.move(:outdent)
234
-
234
+
235
235
  mp3_players.pos.should == [16,19]
236
236
  mp3_players.left_sibling.should == portable_electronics
237
-
237
+
238
238
  mp3_players.move(:higher) # Move up above Portable Electronics
239
-
239
+
240
240
  mp3_players.pos.should == [10,13]
241
241
  mp3_players.left_sibling.should == televisions
242
242
  end
243
243
  end
244
244
  end
245
-
245
+
246
246
  describe 'moving objects with #move_* #and place_node_at' do
247
247
  it 'should set left/right when choosing a parent' do
248
248
  repository(:default) do |repos|
249
249
  Category.auto_migrate!
250
-
250
+
251
251
  c1 = Category.create!(:name => "New Electronics")
252
-
252
+
253
253
  c2 = Category.create!(:name => "OLED TVs")
254
-
254
+
255
255
  c1.pos.should == [1,4]
256
256
  c1.root.should == c1
257
257
  c2.pos.should == [2,3]
258
-
258
+
259
259
  c3 = Category.create(:name => "Portable Electronics")
260
260
  c3.parent=c1
261
261
  c3.save
262
-
262
+
263
263
  c1.pos.should == [1,6]
264
264
  c2.pos.should == [2,3]
265
265
  c3.pos.should == [4,5]
266
-
266
+
267
267
  c3.parent=c2
268
268
  c3.save
269
-
269
+
270
270
  c1.pos.should == [1,6]
271
271
  c2.pos.should == [2,5]
272
272
  c3.pos.should == [3,4]
273
-
273
+
274
274
  c3.parent=c1
275
275
  c3.move(:into => c2)
276
-
276
+
277
277
  c1.pos.should == [1,6]
278
278
  c2.pos.should == [2,5]
279
279
  c3.pos.should == [3,4]
280
-
280
+
281
281
  c4 = Category.create(:name => "Tube", :parent => c2)
282
282
  c5 = Category.create(:name => "Flatpanel", :parent => c2)
283
-
283
+
284
284
  c1.pos.should == [1,10]
285
285
  c2.pos.should == [2,9]
286
286
  c3.pos.should == [3,4]
287
287
  c4.pos.should == [5,6]
288
288
  c5.pos.should == [7,8]
289
-
289
+
290
290
  c5.move(:above => c3)
291
291
  c3.pos.should == [5,6]
292
292
  c4.pos.should == [7,8]
293
293
  c5.pos.should == [3,4]
294
-
294
+
295
295
  end
296
296
  end
297
297
  end
298
-
298
+
299
299
  describe 'scoping' do
300
300
  it 'should detach from list when changing scope' do
301
301
  repository(:default) do |repos|
@@ -308,7 +308,7 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
308
308
  end
309
309
  end
310
310
  end
311
-
311
+
312
312
  describe 'integrity' do
313
313
  it 'should detach object from list when deleted' do
314
314
  repository(:default) do |repos|
data/spec/spec_helper.rb CHANGED
@@ -10,7 +10,7 @@ def load_driver(name, default_uri)
10
10
  lib = "do_#{name}"
11
11
 
12
12
  begin
13
- gem lib, '=0.9.3'
13
+ gem lib, '=0.9.4'
14
14
  require lib
15
15
  DataMapper.setup(name, ENV["#{name.to_s.upcase}_SPEC_URI"] || default_uri)
16
16
  DataMapper::Repository.adapters[:default] = DataMapper::Repository.adapters[name]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-is-nested_set
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sindre Aarsaether
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-24 00:00:00 -05:00
12
+ date: 2008-08-21 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - "="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.3
23
+ version: 0.9.4
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hoe