dm-is-list 0.9.6 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ AUTHOR = "Sindre Aarsaether"
10
10
  EMAIL = "sindre [a] identu [d] no"
11
11
  GEM_NAME = "dm-is-list"
12
12
  GEM_VERSION = DataMapper::Is::List::VERSION
13
- GEM_DEPENDENCIES = [["dm-core", GEM_VERSION]]
13
+ GEM_DEPENDENCIES = [["dm-core", GEM_VERSION], ["dm-adjust", GEM_VERSION]]
14
14
  GEM_CLEAN = ["log", "pkg"]
15
15
  GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO ] }
16
16
 
data/lib/dm-is-list.rb CHANGED
@@ -2,10 +2,10 @@
2
2
  require 'rubygems'
3
3
  require 'pathname'
4
4
 
5
- gem 'dm-core', '=0.9.6'
5
+ gem 'dm-core', '~>0.9.7'
6
6
  require 'dm-core'
7
7
 
8
- gem 'dm-adjust', '=0.9.6'
8
+ gem 'dm-adjust', '~>0.9.7'
9
9
  require 'dm-adjust'
10
10
 
11
11
  require Pathname(__FILE__).dirname.expand_path / 'dm-is-list' / 'is' / 'list.rb'
@@ -150,8 +150,7 @@ module DataMapper
150
150
  # @return <TrueClass, FalseClass> returns false if it cannot move to the position, otherwise true
151
151
  # @see move_without_saving
152
152
  def move(vector)
153
- move_without_saving(vector)
154
- save
153
+ move_without_saving(vector) && save
155
154
  end
156
155
 
157
156
  ##
@@ -166,6 +165,7 @@ module DataMapper
166
165
  minpos = self.class.list_options[:first]
167
166
  prepos = self.original_values[:position] || self.position
168
167
  maxpos = list.last ? (list.last == self ? prepos : list.last.position + 1) : minpos
168
+
169
169
  newpos = case action
170
170
  when :highest then minpos
171
171
  when :lowest then maxpos
@@ -177,6 +177,7 @@ module DataMapper
177
177
  else [action.to_i,maxpos].min
178
178
  end
179
179
 
180
+ return false if [:lower, :higher].include?(action) && newpos == prepos
180
181
  return false if !newpos || ([:above,:below].include?(action) && list_scope != object.list_scope)
181
182
  return true if newpos == position && position == prepos || (newpos == maxpos && position == maxpos-1)
182
183
 
@@ -1,7 +1,7 @@
1
1
  module DataMapper
2
2
  module Is
3
3
  module List
4
- VERSION = "0.9.6"
4
+ VERSION = "0.9.7"
5
5
  end
6
6
  end
7
7
  end
@@ -24,19 +24,19 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
24
24
  is :list, :scope => [:user_id]
25
25
  end
26
26
 
27
- before :all do
27
+ before :each do
28
28
  User.auto_migrate!(:default)
29
29
  Todo.auto_migrate!(:default)
30
30
 
31
- u1 = User.create!(:name => "Johnny")
32
- Todo.create!(:user => u1, :title => "Write down what is needed in a list-plugin")
33
- Todo.create!(:user => u1, :title => "Complete a temporary version of is-list")
34
- Todo.create!(:user => u1, :title => "Squash bugs in nested-set")
31
+ u1 = User.create(:name => "Johnny")
32
+ Todo.create(:user => u1, :title => "Write down what is needed in a list-plugin")
33
+ Todo.create(:user => u1, :title => "Complete a temporary version of is-list")
34
+ Todo.create(:user => u1, :title => "Squash bugs in nested-set")
35
35
 
36
- u2 = User.create!(:name => "Freddy")
37
- Todo.create!(:user => u2, :title => "Eat tasty cupcake")
38
- Todo.create!(:user => u2, :title => "Procrastinate on paid work")
39
- Todo.create!(:user => u2, :title => "Go to sleep")
36
+ u2 = User.create(:name => "Freddy")
37
+ Todo.create(:user => u2, :title => "Eat tasty cupcake")
38
+ Todo.create(:user => u2, :title => "Procrastinate on paid work")
39
+ Todo.create(:user => u2, :title => "Go to sleep")
40
40
 
41
41
  end
42
42
 
@@ -79,11 +79,11 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
79
79
 
80
80
  it 'should rearrange items correctly when moving :lower' do
81
81
  repository(:default) do |repos|
82
- Todo.get(3).position.should == 2
83
- Todo.get(2).position.should == 3
84
- Todo.get(3).move :lower
85
- Todo.get(3).position.should == 3
86
82
  Todo.get(2).position.should == 2
83
+ Todo.get(3).position.should == 3
84
+ Todo.get(2).move :lower
85
+ Todo.get(2).position.should == 3
86
+ Todo.get(3).position.should == 2
87
87
 
88
88
  Todo.get(4).position.should == 1
89
89
  end
@@ -107,23 +107,22 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
107
107
 
108
108
  it 'should not rearrange when trying to move top-item up, or bottom item down' do
109
109
  repository(:default) do |repos|
110
- Todo.get(6).position.should == 1
111
- Todo.get(6).move(:higher).should == false
112
- Todo.get(6).position.should == 1
110
+ Todo.get(4).position.should == 1
111
+ Todo.get(4).move(:higher).should == false
112
+ Todo.get(4).position.should == 1
113
113
 
114
- Todo.get(1).position.should == 3
115
- Todo.get(2).position.should == 1
116
- Todo.get(1).move(:lower).should == false
114
+ Todo.get(6).position.should == 3
115
+ Todo.get(6).move(:lower).should == false
117
116
  end
118
117
  end
119
118
 
120
119
  it 'should rearrange items correctly when moving :above or :below' do
121
120
  repository(:default) do |repos|
122
- Todo.get(6).position.should == 1
123
- Todo.get(5).position.should == 3
124
- Todo.get(6).move(:below => Todo.get(5))
121
+ Todo.get(4).position.should == 1
125
122
  Todo.get(6).position.should == 3
126
- Todo.get(5).position.should == 2
123
+ Todo.get(4).move(:below => Todo.get(6))
124
+ Todo.get(4).position.should == 3
125
+ Todo.get(6).position.should == 2
127
126
  end
128
127
  end
129
128
  end
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.5'
13
+ gem lib, '~>0.9.7'
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-list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.6
4
+ version: 0.9.7
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-10-12 00:00:00 -06:00
12
+ date: 2008-11-18 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,17 @@ dependencies:
20
20
  requirements:
21
21
  - - "="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.6
23
+ version: 0.9.7
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: dm-adjust
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.7
24
34
  version:
25
35
  - !ruby/object:Gem::Dependency
26
36
  name: hoe
@@ -30,7 +40,7 @@ dependencies:
30
40
  requirements:
31
41
  - - ">="
32
42
  - !ruby/object:Gem::Version
33
- version: 1.7.0
43
+ version: 1.8.2
34
44
  version:
35
45
  description: DataMapper plugin for creating and organizing lists
36
46
  email:
@@ -79,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
89
  requirements: []
80
90
 
81
91
  rubyforge_project: datamapper
82
- rubygems_version: 1.2.0
92
+ rubygems_version: 1.3.1
83
93
  signing_key:
84
94
  specification_version: 2
85
95
  summary: DataMapper plugin for creating and organizing lists