+ end\r
+ end\r
+ \r
+ describe '他作家のコマ一覧取得に於いて' do\r
+ before do\r
+ @panel = FactoryGirl.create :panel, :author_id => @author.id\r
+ @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1\r
+ end\r
+ it 'リストを返す' do\r
+ r = Panel.himlist @other_author\r
+ r.should eq [@other_panel]\r
+ end\r
+ it '時系列で並んでいる' do\r
+ npl = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 100\r
+ r = Panel.himlist @other_author\r
+ r.should eq [npl, @other_panel]\r
+ end\r
+ it '公開コマに限る' do\r
+ npl = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 0\r
+ r = Panel.himlist @other_author\r
+ r.should eq [@other_panel]\r
+ end\r
+ context 'DBに5件あって1ページの件数を2件に変えたとして' 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
+ end\r
+ it '通常は2件を返す' do\r
+ pl = Panel.himlist @other_author, 1, 2\r
+ pl.should have(2).items \r
+ end\r
+ it 'page=1なら末尾2件を返す' do\r
+ #時系列で並んでいる\r
+ pl = Panel.himlist @other_author, 1, 2\r
+ pl.should eq [@other_panel5, @other_panel4]\r
+ end\r
+ it 'page=2なら中間2件を返す' do\r
+ pl = Panel.himlist @other_author, 2, 2\r
+ pl.should eq [@other_panel3, @other_panel2]\r
+ end\r
+ it 'page=3なら先頭1件を返す' do\r
+ pl = Panel.himlist @other_author, 3, 2\r
+ pl.should eq [@other_panel]\r
+ end\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
+ 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\r
+ r.should have(5).items\r
+ end\r
+ it 'コマ絵を含んでいる' do\r
+ r = Panel.list_opt\r
+ r.has_key?(:panel_pictures).should be_true\r
+ end\r
+ it 'コマ絵は実素材を含んでいる' do\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\r
+ r[:panel_pictures][:picture].has_key?(:artist).should be_true\r
+ end\r
+ it '実素材はライセンスを含んでいる' do\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\r
+ r.has_key?(:speech_balloons).should be_true\r
+ end\r
+ it 'フキダシはフキダシ枠を含んでいる' do\r
+ r = Panel.list_opt\r
+ r[:speech_balloons].has_key?(:balloon).should be_true\r
+ end\r
+ it 'フキダシはセリフを含んでいる' do\r
+ r = Panel.list_opt\r
+ r[:speech_balloons].has_key?(:speech).should be_true\r
+ end\r
+ it '絵地を含んでいる' do\r
+ r = Panel.list_opt\r
+ r.has_key?(:ground_pictures).should be_true\r
+ end\r
+ it '絵地は実素材を含んでいる' do\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\r
+ r[:ground_pictures][:picture].has_key?(:artist).should be_true\r
+ end\r
+ it '実素材はライセンスを含んでいる' do\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\r
+ r.has_key?(:ground_colors).should be_true\r
+ end\r
+ it '作家を含んでいる' do\r
+ r = Panel.list_opt\r
+ r.has_key?(:author).should be_true\r
+ end\r
+ end\r
+ describe 'json一覧出力オプションに於いて' do\r