@page = Author.page params[:page]
@page_size = Author.comic_page_size params[:page_size]
- @comics = Comic.mylist(@au, @page, @page_size)
+ @comics = Comic.himlist(@au, @page, @page_size)
respond_to do |format|
format.html # index.html.erb
@page = Author.page params[:page]
@page_size = Author.comic_page_size params[:page_size]
- @stories = Story.mylist(@au, @page, @page_size)
+ @stories = Story.himlist(@au, @page, @page_size)
respond_to do |format|
format.html # index.html.erb
@page = Author.page params[:page]
@page_size = Author.panel_page_size params[:page_size]
- @panels = Panel.mylist(@au, @page, @page_size)
+ @panels = Panel.himlist(@au, @page, @page_size)
respond_to do |format|
format.html # index.html.erb
Comic.find(:all, opt)
end
+ def self.himlist au, page = 1, page_size = Author.default_comic_page_size
+ opt = {}
+ opt.merge!(Comic.list_opt)
+ opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
+ opt.merge!({:conditions => ['comics.author_id = ? and visible > 0', au.id], :order => 'comics.updated_at desc'})
+ Comic.find(:all, opt)
+ end
+
def self.show cid, roles
opt = {}
opt.merge!(Comic.show_opt)
Panel.find(:all, opt)
end
+ def self.mylist au, page = 1, page_size = Author.default_panel_page_size
+ opt = {}
+ opt.merge!(self.list_opt)
+ opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
+ opt.merge!({:conditions => ['panels.author_id = ?', au.id], :order => 'panels.updated_at desc'})
+ Panel.find(:all, opt)
+ end
+
+ def self.himlist au, page = 1, page_size = Author.default_panel_page_size
+ opt = {}
+ opt.merge!(self.list_opt)
+ opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
+ opt.merge!({:conditions => ['panels.author_id = ? and panels.publish > 0', au.id], :order => 'panels.updated_at desc'})
+ Panel.find(:all, opt)
+ end
+
def self.list_opt
{:include => {
:panel_pictures => {
}}
end
- def self.mylist au, page = 1, page_size = Author.default_panel_page_size
- opt = {}
- opt.merge!(self.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['panels.author_id = ?', au.id], :order => 'panels.updated_at desc'})
- Panel.find(:all, opt)
- end
-
def self.show rid, roles
opt = {}
opt.merge!(Panel.show_opt)
Story.find(:all, opt)
end
+ def self.himlist au, page = 1, page_size = Author.default_story_page_size
+ opt = {}
+ opt.merge!(Story.list_opt)
+ opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
+ opt.merge!({:conditions => ['stories.author_id = ? and comics.visible > 0', au.id], :order => 'stories.updated_at desc'})
+ Story.find(:all, opt)
+ end
+
def self.show sid, roles
opt = {}
opt.merge!(Story.show_opt)
@other_author = FactoryGirl.create :author, :user_id => @other_user.id
@other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
@comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
- Comic.stub(:mylist).and_return([@comic, @comic, @comic])
+ Comic.stub(:himlist).and_return([@comic, @comic, @comic])
sign_in @user
end
context 'パラメータpageについて' do
get :comics, :id => @other_author.id
end
it 'コミックモデルに一覧を問い合わせている' do
- Comic.should_receive(:mylist).exactly(1)
+ Comic.should_receive(:himlist).exactly(1)
get :comics, :id => @other_author.id
end
it '@comicsにリストを取得している' do
@comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
@panel = FactoryGirl.create :panel, :author_id => @other_user.author.id
@story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @other_user.author.id
- Story.stub(:mylist).and_return([@story, @story, @story])
+ Story.stub(:himlist).and_return([@story, @story, @story])
sign_in @user
end
context 'パラメータpageについて' do
Author.should_receive(:show).exactly(1)
get :stories, :id => @other_author.id
end
- it 'ストーリーモデルに一覧を問い合わせている' do
- Story.should_receive(:mylist).exactly(1)
+ it 'ã\82¹ã\83\88ã\83¼ã\83ªã\83¼ã\83¢ã\83\87ã\83«ã\81«ä»\96ä½\9c家ã\81®ã\82¹ã\83\88ã\83¼ã\83ªã\83¼ä¸\80覧ã\82\92å\95\8fã\81\84å\90\88ã\82\8fã\81\9bã\81¦ã\81\84ã\82\8b' do
+ Story.should_receive(:himlist).exactly(1)
get :stories, :id => @other_author.id
end
it '@storiesにリストを取得している' do
@other_author = FactoryGirl.create :author, :user_id => @other_user.id
@other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
@panel = FactoryGirl.create :panel, :author_id => @other_author.id
- Panel.stub(:mylist).and_return([@panel, @panel, @panel])
+ Panel.stub(:himlist).and_return([@panel, @panel, @panel])
sign_in @user
end
context 'パラメータpageについて' do
Author.should_receive(:show).exactly(1)
get :panels, :id => @other_author.id
end
- it 'コマモデルに一覧を問い合わせている' do
- Panel.should_receive(:mylist).exactly(1)
+ it 'ã\82³ã\83\9eã\83¢ã\83\87ã\83«ã\81«ä»\96ä½\9c家ã\81®ã\82³ã\83\9eä¸\80覧ã\82\92å\95\8fã\81\84å\90\88ã\82\8fã\81\9bã\81¦ã\81\84ã\82\8b' do
+ Panel.should_receive(:himlist).exactly(1)
get :panels, :id => @other_author.id
end
it '@panelsにリストを取得している' do
end
end
+ describe '他作家のコミック一覧取得に於いて' do
+ before do
+ @comic = FactoryGirl.create :comic, :author_id => @author.id
+ @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1
+ end
+ context 'つつがなく終わるとき' do
+ it '一覧取得オプションを利用している' do
+ Comic.stub(:list_opt).with(any_args).and_return({})
+ Comic.should_receive(:list_opt).with(any_args).exactly(1)
+ r = Comic.himlist @other_author
+ end
+ end
+ it '指定した作家のリストを返す' do
+ r = Comic.himlist @other_author
+ r.should eq [@other_comic]
+ end
+ it '時系列で並んでいる' do
+ nc = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 100
+ r = Comic.himlist @other_author
+ r.should eq [nc, @other_comic]
+ end
+ it '公開コミックに限る ' do
+ hidden = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 0
+ r = Comic.himlist @other_author
+ r.should eq [@other_comic]
+ end
+ context 'DBに5件あって1ページの件数を2件に変えたとして' do
+ before do
+ @other_comic2 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 100
+ @other_comic3 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 200
+ @other_comic4 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 300
+ @other_comic5 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 400
+ end
+ it '通常は2件を返す' do
+ c = Comic.himlist @other_author, 1, 2
+ c.should have(2).items
+ end
+ it 'page=1なら末尾2件を返す' do
+ #時系列で並んでいる
+ c = Comic.himlist(@other_author, 1, 2)
+ c.should eq [@other_comic5, @other_comic4]
+ end
+ it 'page=2なら中間2件を返す' do
+ c = Comic.himlist(@other_author, 2, 2)
+ c.should eq [@other_comic3, @other_comic2]
+ end
+ it 'page=3なら先頭1件を返す' do
+ c = Comic.himlist(@other_author, 3, 2)
+ c.should eq [@other_comic]
+ end
+ end
+ context 'DBに5件あって1ページの件数を0件に変えたとして' do
+ before do
+ @other_comic2 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 100
+ @other_comic3 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 200
+ @other_comic4 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 300
+ @other_comic5 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 400
+ Author.stub(:default_comic_page_size).and_return(2)
+ end
+ it '通常は全件(5件)を返す' do
+ r = Comic.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
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
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