end\r
end\r
end\r
+ \r
+ describe '自分のコマ一覧取得に於いて' do\r
+ before do\r
+ @panel = FactoryGirl.create :panel, :author_id => @author.id\r
+ end\r
+ it 'リストを返す' do\r
+ pl = Panel.mylist @author\r
+ pl.should eq [@panel]\r
+ end\r
+ it '時系列で並んでいる' do\r
+ npl = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100\r
+ pl = Panel.mylist @author\r
+ pl.should eq [npl, @panel]\r
+ end\r
+ it '他人のコマは公開でも含まない' do\r
+ npl = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1\r
+ pl = Panel.mylist @author\r
+ pl.should eq [@panel]\r
+ end\r
+ it '自分のコマは非公開でも含んでいる' do\r
+ npl = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0, :updated_at => Time.now + 100\r
+ pl = Panel.mylist @author\r
+ pl.should eq [npl, @panel]\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
+ end\r
+ it '通常は2件を返す' do\r
+ pl = Panel.mylist @author, 1, 2\r
+ pl.should have(2).items \r
+ end\r
+ it 'page=1なら末尾2件を返す' do\r
+ #時系列で並んでいる\r
+ pl = Panel.mylist @author, 1, 2\r
+ pl.should eq [@npl5, @npl4]\r
+ end\r
+ it 'page=2なら中間2件を返す' do\r
+ pl = Panel.mylist @author, 2, 2\r
+ pl.should eq [@npl3, @npl2]\r
+ end\r
+ it 'page=3なら先頭1件を返す' do\r
+ pl = Panel.mylist @author, 3, 2\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
+ 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
+ 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
+ end\r
+ \r
describe '一覧取得オプションに於いて' do\r
it 'includeキーを含んでいる' do\r
r = Panel.list_opt\r
describe 'json一覧出力オプションに於いて' do\r
end\r
\r
- describe '自分のコマ一覧取得に於いて' do\r
- before do\r
- @panel = FactoryGirl.create :panel, :author_id => @author.id\r
- end\r
- it 'リストを返す' do\r
- pl = Panel.mylist @author\r
- pl.should eq [@panel]\r
- end\r
- it '時系列で並んでいる' do\r
- npl = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100\r
- pl = Panel.mylist @author\r
- pl.should eq [npl, @panel]\r
- end\r
- it '他人のコマは公開でも含まない' do\r
- npl = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1\r
- pl = Panel.mylist @author\r
- pl.should eq [@panel]\r
- end\r
- it '自分のコマは非公開でも含んでいる' do\r
- npl = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0, :updated_at => Time.now + 100\r
- pl = Panel.mylist @author\r
- pl.should eq [npl, @panel]\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
- end\r
- it '通常は2件を返す' do\r
- pl = Panel.list 1, 2\r
- pl.should have(2).items \r
- end\r
- it 'page=1なら末尾2件を返す' do\r
- #時系列で並んでいる\r
- pl = Panel.mylist @author, 1, 2\r
- pl.should eq [@npl5, @npl4]\r
- end\r
- it 'page=2なら中間2件を返す' do\r
- pl = Panel.mylist @author, 2, 2\r
- pl.should eq [@npl3, @npl2]\r
- end\r
- it 'page=3なら先頭1件を返す' do\r
- pl = Panel.mylist @author, 3, 2\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
before do\r
@panel = FactoryGirl.create :panel, :author_id => @author.id\r