+ describe 'list関連テーブルプションに於いて' do
+ it 'includeキーを含んでいる' do
+ r = Comic.list_opt
+ r.has_key?(:include).should be_true
+ end
+ it '2つの項目を含んでいる' do
+ r = Comic.list_opt[:include]
+ r.should have(2).items
+ end
+ it 'ストーリーを含んでいる' do
+ r = Comic.list_opt[:include]
+ r.has_key?(:stories).should be_true
+ end
+ it 'ストーリーはコマを含んでいる' do
+ r = Comic.list_opt[:include]
+ r[:stories].has_key?(:panel).should be_true
+ end
+ it '作家を含んでいる' do
+ r = Comic.list_opt[:include]
+ r.has_key?(:author).should be_true
+ end
+ end
+ describe 'json一覧出力オプションに於いて' do
+ it 'includeキーを含んでいる' do
+ r = Comic.list_json_opt
+ r.has_key?(:include).should be_true
+ end
+ it '2つの項目を含んでいる' do
+ r = Comic.list_json_opt[:include]
+ r.should have(2).items
+ end
+ it 'ストーリーを含んでいる' do
+ r = Comic.list_json_opt[:include]
+ r.has_key?(:stories).should be_true
+ end
+ it 'ストーリーはコマを含んでいる' do
+ r = Comic.list_json_opt[:include]
+ r[:stories].has_key?(:panel).should be_true
+ end
+ it '作家を含んでいる' do
+ r = Comic.list_json_opt[:include]
+ r.has_key?(:author).should be_true
+ end
+ end
+
+ describe '自分のコミック一覧取得に於いて' do
+ before do
+ @comic = FactoryGirl.create :comic, :author_id => @author.id
+ end
+ it 'リストを返す' do
+ c = Comic.mylist @author
+ c.should eq [@comic]
+ end
+ it '時系列で並んでいる' do
+ nc = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 100
+ cl = Comic.mylist @author
+ cl.should eq [nc, @comic]
+ end
+ it '他人のコミックは公開でも含まない' do
+ nc = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1
+ cl = Comic.mylist @author
+ cl.should eq [@comic]
+ end
+ it '自分のコミックは非公開でも含んでいる' do
+ nc = FactoryGirl.create :comic, :author_id => @author.id, :visible => 0, :updated_at => Time.now + 100
+ cl = Comic.mylist @author
+ cl.should eq [nc, @comic]
+ end
+ end
+