+ it '公開コマに限る' do
+ hidden_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 0
+ hidden_gp = FactoryGirl.create :ground_picture, :panel_id => hidden_panel.id, :picture_id => @p.id, :updated_at => Time.now + 100
+ r = GroundPicture.himlist @other_author
+ r.should eq [@other_gp]
+ end
+ context 'DBに5件あって1ページの件数を2件に変えたとして' do
+ before do
+ @other_gp2 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 100
+ @other_gp3 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 200
+ @other_gp4 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 300
+ @other_gp5 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 400
+ end
+ it '通常は2件を返す' do
+ pl = GroundPicture.himlist @other_author, 1, 2
+ pl.should have(2).items
+ end
+ it 'page=1なら末尾2件を返す' do
+ #時系列で並んでいる
+ pl = GroundPicture.himlist @other_author, 1, 2
+ pl.should eq [@other_gp5, @other_gp4]
+ end
+ it 'page=2なら中間2件を返す' do
+ pl = GroundPicture.himlist @other_author, 2, 2
+ pl.should eq [@other_gp3, @other_gp2]
+ end
+ it 'page=3なら先頭1件を返す' do
+ pl = GroundPicture.himlist @other_author, 3, 2
+ pl.should eq [@other_gp]
+ end
+ end
+ end
+
+ describe '絵地一覧ページ制御に於いて' do
+ before do
+ GroundPicture.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = GroundPicture.list_paginate
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '絵地一覧の取得条件を利用している' do
+ GroundPicture.stub(:list_where).with(any_args).and_return('')
+ GroundPicture.should_receive(:list_where).with(any_args).exactly(1)
+ r = GroundPicture.list_paginate
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = GroundPicture.list_paginate 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
+ end
+ end
+
+ describe '自分の絵地一覧ページ制御に於いて' do
+ before do
+ GroundPicture.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = GroundPicture.mylist_paginate @author
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '自分の絵地一覧の取得条件を利用している' do
+ GroundPicture.stub(:mylist_where).with(any_args).and_return('')
+ GroundPicture.should_receive(:mylist_where).with(any_args).exactly(1)
+ r = GroundPicture.mylist_paginate @author
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = GroundPicture.mylist_paginate @author, 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
+ end
+ end
+
+ describe '他作家の絵地一覧ページ制御に於いて' do
+ before do
+ GroundPicture.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = GroundPicture.himlist_paginate @other_author
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '他作家の絵地一覧の取得条件を利用している' do
+ GroundPicture.stub(:himlist_where).with(any_args).and_return('')
+ GroundPicture.should_receive(:himlist_where).with(any_args).exactly(1)
+ r = GroundPicture.himlist_paginate @other_author
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = GroundPicture.himlist_paginate @other_author, 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
+ end
+ end
+
+ describe '一覧取得オプションに於いて' do