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