positionable 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/positionable.rb +2 -2
- data/lib/positionable/version.rb +1 -1
- data/positionable.gemspec +1 -1
- data/spec/lib/positionable_spec.rb +15 -7
- metadata +15 -16
data/lib/positionable.rb
CHANGED
@@ -91,9 +91,9 @@ module Positionable
|
|
91
91
|
count = self.class.where("#{scope_id_attr} = ?", target_scope_id).count
|
92
92
|
# An additional position is available if this record is new, or if it's moved to another scope
|
93
93
|
if new_record? or target_scope_id != scope_id
|
94
|
-
(start..(
|
94
|
+
(start..(start + count))
|
95
95
|
else
|
96
|
-
(start..count)
|
96
|
+
(start..(start + count - 1))
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
data/lib/positionable/version.rb
CHANGED
data/positionable.gemspec
CHANGED
@@ -451,20 +451,28 @@ describe Positionable do
|
|
451
451
|
it "gives the range within a scope" do
|
452
452
|
folder = Factory.create(:folder_with_documents)
|
453
453
|
document = Document.new
|
454
|
-
document.range(folder).should == (0..
|
454
|
+
document.range(folder).should == (0..folder.documents.count)
|
455
455
|
end
|
456
456
|
|
457
457
|
it "gives the range within its own scope by default" do
|
458
|
-
|
459
|
-
|
460
|
-
document.range.should == (0..(folder.documents.count
|
458
|
+
folder = Factory.create(:folder_with_documents)
|
459
|
+
document = folder.documents.sample
|
460
|
+
document.range.should == (0..(folder.documents.count - 1))
|
461
461
|
end
|
462
462
|
|
463
463
|
it "gives the range within another scope" do
|
464
464
|
document = Factory.build(:document)
|
465
465
|
folder = Factory.create(:folder_with_documents)
|
466
466
|
document.folder.should_not == folder # Meta!
|
467
|
-
document.range(folder).should == (0..
|
467
|
+
document.range(folder).should == (0..folder.documents.count)
|
468
|
+
end
|
469
|
+
|
470
|
+
it "gives the range within another empty scope" do
|
471
|
+
document = Factory.build(:document)
|
472
|
+
folder = Factory.create(:folder)
|
473
|
+
document.folder.should_not == folder # Meta!
|
474
|
+
folder.documents.should be_empty # Meta!
|
475
|
+
document.range(folder).should == (0..0)
|
468
476
|
end
|
469
477
|
|
470
478
|
end
|
@@ -474,14 +482,14 @@ describe Positionable do
|
|
474
482
|
it "gives the range within its own scope" do
|
475
483
|
folder = Factory.create(:folder_with_documents)
|
476
484
|
document = folder.documents.sample
|
477
|
-
document.range(folder).should == (0..folder.documents.count)
|
485
|
+
document.range(folder).should == (0..(folder.documents.count - 1))
|
478
486
|
end
|
479
487
|
|
480
488
|
it "gives the range within another scope" do
|
481
489
|
document = Factory.create(:document)
|
482
490
|
folder = Factory.create(:folder_with_documents)
|
483
491
|
document.folder.should_not == folder # Meta!
|
484
|
-
document.range(folder).should == (0..
|
492
|
+
document.range(folder).should == (0..folder.documents.count)
|
485
493
|
end
|
486
494
|
|
487
495
|
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.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-03-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &70099336314860 !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: *70099336314860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70099336314240 !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: *70099336314240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sqlite3-ruby
|
38
|
-
requirement: &
|
38
|
+
requirement: &70099336313540 !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: *70099336313540
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: simplecov
|
49
|
-
requirement: &
|
49
|
+
requirement: &70099336312400 !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: *70099336312400
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: factory_girl
|
60
|
-
requirement: &
|
60
|
+
requirement: &70099336311600 !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: *70099336311600
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activerecord
|
71
|
-
requirement: &
|
71
|
+
requirement: &70099336310240 !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: *70099336310240
|
80
80
|
description: This extension provides contiguous positionning capabilities to you ActiveRecord
|
81
81
|
models.
|
82
82
|
email:
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project: positionable
|
123
|
-
rubygems_version: 1.8.
|
123
|
+
rubygems_version: 1.8.17
|
124
124
|
signing_key:
|
125
125
|
specification_version: 3
|
126
126
|
summary: A gem for positionning your ActiveRecord models.
|
@@ -131,4 +131,3 @@ test_files:
|
|
131
131
|
- spec/support/matchers/contiguity_matcher.rb
|
132
132
|
- spec/support/models.rb
|
133
133
|
- spec/support/schema.rb
|
134
|
-
has_rdoc:
|