positionable 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/positionable/version.rb +1 -1
- data/spec/lib/positionable_spec.rb +15 -13
- data/spec/support/matchers/contiguity_matcher.rb +1 -0
- metadata +13 -13
data/lib/positionable/version.rb
CHANGED
@@ -39,7 +39,7 @@ describe Positionable do
|
|
39
39
|
item = Factory.create(:default_item)
|
40
40
|
item.update_column(:position, position)
|
41
41
|
end
|
42
|
-
DefaultItem.all.should be_contiguous
|
42
|
+
DefaultItem.all.should be_contiguous.starting_at(0)
|
43
43
|
end
|
44
44
|
|
45
45
|
end
|
@@ -109,7 +109,7 @@ describe Positionable do
|
|
109
109
|
it "decrements positions of next sibblings after deletion" do
|
110
110
|
position = items.size / 2
|
111
111
|
middle.destroy
|
112
|
-
items.before(position).should be_contiguous
|
112
|
+
items.before(position).should be_contiguous.starting_at(0)
|
113
113
|
items.after(position).should be_contiguous.starting_at(position)
|
114
114
|
end
|
115
115
|
|
@@ -173,12 +173,12 @@ describe Positionable do
|
|
173
173
|
|
174
174
|
it "does not reorder anything when position is updated but out of range" do
|
175
175
|
middle.update_attributes({ :position => items.count + 10 })
|
176
|
-
items.should be_contiguous
|
176
|
+
items.should be_contiguous.starting_at(0)
|
177
177
|
end
|
178
178
|
|
179
179
|
it "does not reorder anything when position is updated but before start" do
|
180
180
|
middle.update_attributes({ :position => -1 })
|
181
|
-
items.should be_contiguous
|
181
|
+
items.should be_contiguous.starting_at(0)
|
182
182
|
end
|
183
183
|
|
184
184
|
end
|
@@ -258,7 +258,7 @@ describe Positionable do
|
|
258
258
|
document.update_column(:position, shuffled_positions[index])
|
259
259
|
end
|
260
260
|
documents = folder.reload.documents
|
261
|
-
documents.should be_contiguous
|
261
|
+
documents.should be_contiguous.starting_at(0)
|
262
262
|
end
|
263
263
|
end
|
264
264
|
|
@@ -352,7 +352,7 @@ describe Positionable do
|
|
352
352
|
documents = folder.documents
|
353
353
|
middle = documents.size / 2
|
354
354
|
documents[middle].destroy
|
355
|
-
documents.before(middle).should be_contiguous
|
355
|
+
documents.before(middle).should be_contiguous.starting_at(0)
|
356
356
|
documents.after(middle).should be_contiguous.starting_at(middle)
|
357
357
|
end
|
358
358
|
end
|
@@ -361,8 +361,9 @@ describe Positionable do
|
|
361
361
|
folders.each do |folder|
|
362
362
|
document = folder.documents.first
|
363
363
|
document.position.should == 0 # Meta!
|
364
|
-
|
365
|
-
|
364
|
+
lambda {
|
365
|
+
document.up!
|
366
|
+
}.should_not change(document, :position)
|
366
367
|
end
|
367
368
|
end
|
368
369
|
|
@@ -370,8 +371,9 @@ describe Positionable do
|
|
370
371
|
folders.each do |folder|
|
371
372
|
document = folder.documents.last
|
372
373
|
document.position.should == folder.documents.size - 1 # Meta!
|
373
|
-
|
374
|
-
|
374
|
+
lambda {
|
375
|
+
document.down!
|
376
|
+
}.should_not change(document, :position)
|
375
377
|
end
|
376
378
|
end
|
377
379
|
|
@@ -426,12 +428,12 @@ describe Positionable do
|
|
426
428
|
position = document.position
|
427
429
|
document.update_attributes( {:folder_id => new_folder.id} )
|
428
430
|
document.position.should == position # Position unchanged
|
429
|
-
new_folder.reload.documents.should be_contiguous
|
431
|
+
new_folder.reload.documents.should be_contiguous.starting_at(0)
|
430
432
|
end
|
431
433
|
|
432
434
|
it "reorders records of previous scope" do
|
433
435
|
document.update_attributes( {:folder_id => new_folder.id} )
|
434
|
-
old_folder.reload.documents.should be_contiguous
|
436
|
+
old_folder.reload.documents.should be_contiguous.starting_at(0)
|
435
437
|
end
|
436
438
|
|
437
439
|
end
|
@@ -571,7 +573,7 @@ describe Positionable do
|
|
571
573
|
|
572
574
|
it "orders items by descending position" do
|
573
575
|
items = FactoryGirl.create_list(:desc_item, 5)
|
574
|
-
DescItem.all.reverse.should be_contiguous
|
576
|
+
DescItem.all.reverse.should be_contiguous.starting_at(0)
|
575
577
|
end
|
576
578
|
|
577
579
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: positionable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &70142130433320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70142130433320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70142130421500 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '2.3'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70142130421500
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sqlite3-ruby
|
38
|
-
requirement: &
|
38
|
+
requirement: &70142130410640 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70142130410640
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: simplecov
|
49
|
-
requirement: &
|
49
|
+
requirement: &70142130403860 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70142130403860
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: factory_girl
|
60
|
-
requirement: &
|
60
|
+
requirement: &70142126204520 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70142126204520
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activerecord
|
71
|
-
requirement: &
|
71
|
+
requirement: &70142121886120 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '3.1'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70142121886120
|
80
80
|
description: This extension provides contiguous positionning capabilities to you ActiveRecord
|
81
81
|
models.
|
82
82
|
email:
|