end
end
end
+
describe '自分のストーリー一覧取得に於いて' do
before do
@comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
end
end
+ describe '他作家のストーリー一覧取得に於いて' do
+ before do
+ @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
+ @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
+ @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
+ @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1
+ @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
+ @other_story = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id
+ end
+ it 'リストを返す' do
+ r = Story.himlist @other_author
+ r.should eq [@other_story]
+ end
+ it '時系列で並んでいる' do
+ ns = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 1, :updated_at => Time.now + 100
+ r = Story.himlist @other_author
+ r.should eq [ns, @other_story]
+ end
+ it '公開コミックのストーリー' do
+ @hcomic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 0
+ ns = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @hcomic.id, :panel_id => @other_panel.id, :t => 1, :updated_at => Time.now + 100
+ r = Story.himlist @other_author
+ r.should eq [@other_story]
+ end
+ context 'DBに5件あって1ページの件数を2件に変えたとして' do
+ before do
+ @other_story2 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 1, :updated_at => Time.now + 100
+ @other_story3 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 2, :updated_at => Time.now + 200
+ @other_story4 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 3, :updated_at => Time.now + 300
+ @other_story5 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 4, :updated_at => Time.now + 400
+ Story.stub(:default_page_size).and_return(2)
+ end
+ it '通常は2件を返す' do
+ l = Story.himlist @other_author, 1, 2
+ l.should have(2).items
+ end
+ it 'page=1なら末尾2件を返す' do
+ #時系列で並んでいる
+ l = Story.himlist @other_author, 1, 2
+ l.should eq [@other_story5, @other_story4]
+ end
+ it 'page=2なら中間2件を返す' do
+ l = Story.himlist @other_author, 2, 2
+ l.should eq [@other_story3, @other_story2]
+ end
+ it 'page=3なら先頭1件を返す' do
+ l = Story.himlist @other_author, 3, 2
+ l.should eq [@other_story]
+ end
+ end
+ context 'DBに5件あって1ページの件数を2件に変えたとして' do
+ before do
+ @other_story2 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 1, :updated_at => Time.now + 100
+ @other_story3 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 2, :updated_at => Time.now + 200
+ @other_story4 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 3, :updated_at => Time.now + 300
+ @other_story5 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 4, :updated_at => Time.now + 400
+ Author.stub(:default_story_page_size).and_return(2)
+ end
+ it '件数0は全件(5件)を返す' do
+ r = Story.himlist @other_author, 5, 0
+ r.should have(5).items
+ end
+ end
+ end
+
describe '単体取得に於いて' do
before do
@comic = FactoryGirl.create :comic, :author_id => @author.id