pl.should eq [@panel]\r
end\r
end\r
- context 'DBに5件あって1ページの件数を2件に変えたとして' do\r
- before do\r
- @npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100\r
- @npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200\r
- @npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300\r
- @npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400\r
- Panel.stub(:default_page_size).and_return(2)\r
- end\r
- it '件数0は全件(5件)を返す' do\r
- r = Panel.list 5, 0\r
- r.should have(5).items \r
- end\r
- end\r
end\r
\r
describe '自分のコマ一覧取得に於いて' do\r
pl.should eq [@panel]\r
end\r
end\r
- context 'DBに5件あって1ページの件数を0件に変えたとして' do\r
- before do\r
- @npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100\r
- @npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200\r
- @npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300\r
- @npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400\r
- Author.stub(:default_panel_page_size).and_return(2)\r
- end\r
- it '通常は全件(5件)を返す' do\r
- r = Panel.mylist @author, 5, 0\r
- r.should have(5).items \r
- end\r
- end\r
end\r
\r
describe '他作家のコマ一覧取得に於いて' do\r
pl.should eq [@other_panel]\r
end\r
end\r
- context 'DBに5件あって1ページの件数を0件に変えたとして' do\r
- before do\r
- @other_panel2 = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 100\r
- @other_panel3 = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 200\r
- @other_panel4 = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 300\r
- @other_panel5 = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 400\r
- Author.stub(:default_panel_page_size).and_return(2)\r
- end\r
- it '通常は全件(5件)を返す' do\r
- r = Panel.himlist @other_author, 5, 0\r
- r.should have(5).items \r
- end\r
+ end\r
+ \r
+ describe 'コマ一覧ページ制御に於いて' do\r
+ before do\r
+ Panel.stub(:count).with(any_args).and_return(100)\r
+ end\r
+ it 'ページ制御を返す' do\r
+ r = Panel.list_paginate \r
+ r.is_a?(Kaminari::PaginatableArray).should be_true\r
+ end\r
+ it 'コマ一覧の取得条件を利用している' do\r
+ Panel.stub(:list_where).with(any_args).and_return('')\r
+ Panel.should_receive(:list_where).with(any_args).exactly(1)\r
+ r = Panel.list_paginate \r
+ end\r
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do\r
+ r = Panel.list_paginate 3, 10\r
+ r.limit_value.should eq 10\r
+ r.offset_value.should eq 20\r
end\r
end\r
\r
- describe '一覧取得オプションに於いて' do\r
- it 'includeキーを含んでいる' do\r
- r = Panel.list_opt\r
- r.has_key?(:include).should be_true\r
+ describe '自分のコマ一覧ページ制御に於いて' do\r
+ before do\r
+ Panel.stub(:count).with(any_args).and_return(100)\r
+ end\r
+ it 'ページ制御を返す' do\r
+ r = Panel.mylist_paginate @author\r
+ r.is_a?(Kaminari::PaginatableArray).should be_true\r
+ end\r
+ it '自分のコマ一覧の取得条件を利用している' do\r
+ Panel.stub(:mylist_where).with(any_args).and_return('')\r
+ Panel.should_receive(:mylist_where).with(any_args).exactly(1)\r
+ r = Panel.mylist_paginate @author\r
+ end\r
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do\r
+ r = Panel.mylist_paginate @author, 3, 10\r
+ r.limit_value.should eq 10\r
+ r.offset_value.should eq 20\r
end\r
+ end\r
+ \r
+ describe '他作家のコマ一覧ページ制御に於いて' do\r
+ before do\r
+ Panel.stub(:count).with(any_args).and_return(100)\r
+ end\r
+ it 'ページ制御を返す' do\r
+ r = Panel.himlist_paginate @other_author\r
+ r.is_a?(Kaminari::PaginatableArray).should be_true\r
+ end\r
+ it '他作家のコマ一覧の取得条件を利用している' do\r
+ Panel.stub(:himlist_where).with(any_args).and_return('')\r
+ Panel.should_receive(:himlist_where).with(any_args).exactly(1)\r
+ r = Panel.himlist_paginate @other_author\r
+ end\r
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do\r
+ r = Panel.himlist_paginate @other_author, 3, 10\r
+ r.limit_value.should eq 10\r
+ r.offset_value.should eq 20\r
+ end\r
+ end\r
+ \r
+ describe '一覧取得オプションに於いて' do\r
it '5つの項目を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r.should have(5).items\r
end\r
it 'コマ絵を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r.has_key?(:panel_pictures).should be_true\r
end\r
it 'コマ絵は実素材を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:panel_pictures].has_key?(:picture).should be_true\r
end\r
it '実素材は絵師を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:panel_pictures][:picture].has_key?(:artist).should be_true\r
end\r
it '実素材はライセンスを含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:panel_pictures][:picture].has_key?(:license).should be_true\r
end\r
it 'フキダシを含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r.has_key?(:speech_balloons).should be_true\r
end\r
it 'フキダシはフキダシ枠を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:speech_balloons].has_key?(:balloons).should be_true\r
end\r
it 'フキダシはセリフを含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:speech_balloons].has_key?(:speeches).should be_true\r
end\r
it '絵地を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r.has_key?(:ground_pictures).should be_true\r
end\r
it '絵地は実素材を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:ground_pictures].has_key?(:picture).should be_true\r
end\r
it '実素材は絵師を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:ground_pictures][:picture].has_key?(:artist).should be_true\r
end\r
it '実素材はライセンスを含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:ground_pictures][:picture].has_key?(:license).should be_true\r
end\r
it '色地を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r.has_key?(:ground_colors).should be_true\r
end\r
it '作家を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r.has_key?(:author).should be_true\r
end\r
end\r