acts_as_restful_list 0.2.0 → 0.2.1
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/VERSION +1 -1
- data/acts_as_restful_list.gemspec +3 -3
- data/lib/acts_as_restful_list.rb +1 -1
- data/spec/acts_as_restful_list_spec.rb +8 -0
- metadata +20 -9
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{acts_as_restful_list}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["'Trey Bean'"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-03-24}
|
13
13
|
s.description = %q{Just like acts_as_list, but allows updating through standard restful methods.}
|
14
14
|
s.email = %q{trey@12spokes.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.homepage = %q{http://github.com/12spokes/acts_as_restful_list}
|
35
35
|
s.rdoc_options = ["--charset=UTF-8"]
|
36
36
|
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = %q{1.3.
|
37
|
+
s.rubygems_version = %q{1.3.6}
|
38
38
|
s.summary = %q{Restful acts_as_list}
|
39
39
|
s.test_files = [
|
40
40
|
"spec/acts_as_restful_list_spec.rb",
|
data/lib/acts_as_restful_list.rb
CHANGED
@@ -47,7 +47,7 @@ module ActsAsRestfulList
|
|
47
47
|
def reset_order_after_update
|
48
48
|
if self.send( "#{position_column}_changed?" )
|
49
49
|
if self.send( "#{position_column}_was" ) > self.send( position_column )
|
50
|
-
self.class.update_all("#{position_column} = (#{position_column} + 1)", [scope_condition, "#{position_column} >= #{self.send( position_column )}", "id != #{id}"].compact.join(' AND '))
|
50
|
+
self.class.update_all("#{position_column} = (#{position_column} + 1)", [scope_condition, "#{position_column} >= #{self.send( position_column )}", "id != #{id}", "#{position_column} < #{self.send( "#{position_column}_was" )}"].compact.join(' AND '))
|
51
51
|
else
|
52
52
|
self.class.update_all("#{position_column} = (#{position_column} - 1)", [scope_condition, "#{position_column} <= #{self.send( position_column )}", "#{position_column} >= #{self.send( "#{position_column}_was" )}", "id != #{id}"].compact.join(' AND '))
|
53
53
|
end
|
@@ -69,6 +69,14 @@ describe "ActsAsRestfulList" do
|
|
69
69
|
Mixin.all(:order => 'position ASC').collect(&:position).should == [1,2,3,4]
|
70
70
|
end
|
71
71
|
|
72
|
+
it 'should reorder the list correctly if a record in the middle is updated with a lower position' do
|
73
|
+
third_mixin = Mixin.first( :conditions => { :position => 3 } )
|
74
|
+
third_mixin.position = 2
|
75
|
+
third_mixin.save!
|
76
|
+
third_mixin.reload.position.should == 2
|
77
|
+
Mixin.all(:order => 'position ASC').collect(&:position).should == [1,2,3,4]
|
78
|
+
end
|
79
|
+
|
72
80
|
it 'should automatically reorder the list if a record is updated with a higher position' do
|
73
81
|
second_mixin = Mixin.first( :conditions => { :position => 2 } )
|
74
82
|
second_mixin.position = 4
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_restful_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- "'Trey Bean'"
|
@@ -9,19 +14,23 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-03-24 00:00:00 -06:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rspec
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 2
|
30
|
+
- 9
|
23
31
|
version: 1.2.9
|
24
|
-
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
25
34
|
description: Just like acts_as_list, but allows updating through standard restful methods.
|
26
35
|
email: trey@12spokes.com
|
27
36
|
executables: []
|
@@ -58,18 +67,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
67
|
requirements:
|
59
68
|
- - ">="
|
60
69
|
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
61
72
|
version: "0"
|
62
|
-
version:
|
63
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
74
|
requirements:
|
65
75
|
- - ">="
|
66
76
|
- !ruby/object:Gem::Version
|
77
|
+
segments:
|
78
|
+
- 0
|
67
79
|
version: "0"
|
68
|
-
version:
|
69
80
|
requirements: []
|
70
81
|
|
71
82
|
rubyforge_project:
|
72
|
-
rubygems_version: 1.3.
|
83
|
+
rubygems_version: 1.3.6
|
73
84
|
signing_key:
|
74
85
|
specification_version: 3
|
75
86
|
summary: Restful acts_as_list
|