positionable 1.0.6 → 1.0.7
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/lib/positionable.rb +5 -1
- data/lib/positionable/version.rb +1 -1
- data/spec/factories.rb +2 -2
- data/spec/lib/positionable_spec.rb +10 -0
- metadata +2 -2
data/lib/positionable.rb
CHANGED
@@ -100,7 +100,11 @@ module Positionable
|
|
100
100
|
private
|
101
101
|
|
102
102
|
def scoped_condition
|
103
|
-
|
103
|
+
if scope_id.nil?
|
104
|
+
"#{scope_id_attr} is null"
|
105
|
+
else
|
106
|
+
"#{scope_id_attr} = " + scope_id.to_s
|
107
|
+
end
|
104
108
|
end
|
105
109
|
|
106
110
|
def scoped_position
|
data/lib/positionable/version.rb
CHANGED
data/spec/factories.rb
CHANGED
@@ -4,7 +4,7 @@ FactoryGirl.define do
|
|
4
4
|
sequence(:title) { |n| "Folder #{n}" }
|
5
5
|
|
6
6
|
factory :folder_with_documents do
|
7
|
-
|
7
|
+
after(:create) do |folder|
|
8
8
|
folder.documents = FactoryGirl.create_list(:document, 5, :folder => folder)
|
9
9
|
end
|
10
10
|
end
|
@@ -43,7 +43,7 @@ FactoryGirl.define do
|
|
43
43
|
sequence(:title) { |n| "Group #{n}" }
|
44
44
|
|
45
45
|
factory :group_with_complex_items do
|
46
|
-
|
46
|
+
after(:create) do |group|
|
47
47
|
group.complex_items = FactoryGirl.create_list(:complex_item, 5, :group => group)
|
48
48
|
end
|
49
49
|
end
|
@@ -432,6 +432,16 @@ describe Positionable do
|
|
432
432
|
end
|
433
433
|
end
|
434
434
|
|
435
|
+
context "missing scope reference" do
|
436
|
+
|
437
|
+
it "supports nil scope reference" do
|
438
|
+
create(:document, folder: nil).position.should == 0
|
439
|
+
create(:document, folder: nil).position.should == 1
|
440
|
+
create(:document, folder: nil).position.should == 2
|
441
|
+
end
|
442
|
+
|
443
|
+
end
|
444
|
+
|
435
445
|
context "changing scope" do
|
436
446
|
|
437
447
|
let!(:old_folder) { folders.first }
|
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.7
|
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-
|
12
|
+
date: 2012-06-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|