+ #例外ケース。
+ #負のときは0として正常扱い
+ context 'テーブルに2件(t:0,1)で1を-1に移動したとき' do
+ before do
+ @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+ @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+ @ot = @story2.t
+ @story2.t = -1
+ end
+ it '既存のt0を1にシフトしてこれから挿入するt(0)が欠番になっている' do
+ #移動させたい行はそのまま残る
+ @story2.lesser_shift @ot
+ l = Story.find(:all).map {|s| s.t }
+ l.sort.should eq [1, 1]
+ end
+ it '既存のt0を1にシフトしている' do
+ @story2.lesser_shift @ot
+ @story.reload
+ @story.t.should eq 1
+ end
+ it '既存のt1は0に補正されている' do
+ @story2.lesser_shift @ot
+ @story2.t.should eq 0
+ end
+ end