datamapper/dm-is-list — Issue #3: `move :below` fails
Author: FND
Created: 2011-10-14 08:04:18+00:00
State: open

test case: https://github.com/FND/dm-is-list/compare/below_bug

the first `.move :below` fails - yet it succeeds if first doing an arbitrary `.move :above`

Since the RSpec test case seems potentially confusing, here's a sample script that might make it clearer:

module DEBUG

def self.info
puts Animal.all(:order => :position.asc).map(&:id).join(" ")
end

def self.move(id, vector, ref_id)
puts Animal.get!(id).move vector => Animal.get!(ref_id)
end

end

5.times do |i|
name = "animal#{i}"
Animal.create
end

DEBUG::info # 1 2 3 4 5
DEBUG::move 5, :below, 1 # false
DEBUG::info # 1 2 3 4 5
DEBUG::move 5, :above, 1 # true
DEBUG::info # 5 1 2 3 4
DEBUG::move 5, :below, 1 # true
DEBUG::info # 1 5 2 3 4