
dm-is-list not updating positioning for new instances
Reported by Mark Lynn | March 19th, 2009 @ 01:56 PM | in 0.10.0
The following test fails for dm-list
require 'pathname'
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
describe 'DataMapper::Is::List' do
class User
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :todos
end
class Todo
include DataMapper::Resource
property :id, Serial
property :title, String
belongs_to :user
is :list, :scope => [:user_id]
end
before :each do
User.auto_migrate!(:default)
Todo.auto_migrate!(:default)
end
it 'should rearrange items when setting position yourself on newly created items' do
u3 = User.create(:name => "Mark")
todo1 = Todo.create(:user => u3, :title => "Cleanup garage")
todo2 = Todo.create(:user => u3, :title => "Cleanup yard")
todo3 = Todo.create(:user => u3, :title => "Cleanup basement")
todo3.position = 1
todo3.save
Todo.get(todo3.id).position.should == 1
Todo.get(todo1.id).position.should == 2
end
end
end
The problem appears to be that the moved flag is set true during object creation and not cleared. This can be fixed by setting moved=false in before :create block or alternatively adding a block such as
after :save do
self.moved = false
end
Comments and changes to this ticket
-
Martin Gamsjaeger (snusnu) July 9th, 2009 @ 06:47 PM
- State changed from unconfirmed to duplicate
- Milestone set to 0.10.0
I marked this as a duplicate of #891 even though this one was here earlier and probably isn't related to the exact same problem. The reason however, is that it looks like most (recent) discussion on this is going on at #891 and there is already one person who claims it has a rather complete fix for dm-is-list behavior in his fork. I added a reference to this ticket over at #891
-
Martin Gamsjaeger (snusnu) July 9th, 2009 @ 08:01 PM
- State changed from duplicate to accepted
Changed to accepted just to make sure we're not missing something. See #891 for further progress.
-
Martin Gamsjaeger (snusnu) July 9th, 2009 @ 08:01 PM
- Assigned user set to Martin Gamsjaeger (snusnu)
-
Martin Gamsjaeger (snusnu) July 14th, 2009 @ 09:32 AM
- State changed from accepted to resolved
Resolved as of
http://github.com/datamapper/dm-more/commit/e497c24c925223c935c5f2c...
Thx again kematzy!
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »