end
end
end
- describe '一覧取得オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = OriginalPicture.list_opt
- r.has_key?(:include).should be_true
- end
- it '2つの項目を含んでいる' do
- r = OriginalPicture.list_opt[:include]
- r.should have(2).items
- end
- it '素材を含んでいる' do
- r = OriginalPicture.list_opt[:include]
- r.has_key?(:resource_picture).should be_true
- end
- it '実素材を含んでいる' do
- r = OriginalPicture.list_opt[:include]
- r.has_key?(:pictures).should be_true
- end
- end
- describe 'json一覧出力オプションに於いて' do
- before do
- @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
- @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
- @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
- @sbt = FactoryGirl.create :speech_balloon_template
- @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
- end
- it '素材を含んでいる' do
- r = OriginalPicture.mylist(@artist).to_json OriginalPicture.list_json_opt
- j = JSON.parse r
- i = j.first
- i.has_key?('resource_picture').should be_true
- end
- it '実素材を含んでいる' do
- r = OriginalPicture.mylist(@artist).to_json OriginalPicture.list_json_opt
- j = JSON.parse r
- i = j.first
- i.has_key?('pictures').should be_true
- end
- end
describe '自分の原画一覧取得に於いて' do
before do
r.should eq [@op]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
- before do
- @op2 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 100
- @op3 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 200
- @op4 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 300
- @op5 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 400
- OriginalPicture.stub(:default_page_size).and_return(2)
- end
- it '通常は全件(5件)を返す' do
- r = OriginalPicture.mylist @artist, 5, 0
- r.should have(5).items
- end
+ end
+
+ describe '自分の原画一覧ページ制御に於いて' do
+ before do
+ OriginalPicture.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = OriginalPicture.mylist_paginate @author
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '自分の原画一覧の取得条件を利用している' do
+ OriginalPicture.stub(:mylist_where).with(any_args).and_return('')
+ OriginalPicture.should_receive(:mylist_where).with(any_args).exactly(1)
+ r = OriginalPicture.mylist_paginate @author
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = OriginalPicture.mylist_paginate @author, 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
+ end
+ end
+
+ describe '一覧取得オプションに於いて' do
+ it '2つの項目を含んでいる' do
+ r = OriginalPicture.list_opt
+ r.should have(2).items
+ end
+ it '素材を含んでいる' do
+ r = OriginalPicture.list_opt
+ r.has_key?(:resource_picture).should be_true
+ end
+ it '実素材を含んでいる' do
+ r = OriginalPicture.list_opt
+ r.has_key?(:pictures).should be_true
+ end
+ end
+ describe 'json一覧出力オプションに於いて' do
+ before do
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
+ @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
+ @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
+ @sbt = FactoryGirl.create :speech_balloon_template
+ @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
+ end
+ it '素材を含んでいる' do
+ r = OriginalPicture.mylist(@artist).to_json OriginalPicture.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ i.has_key?('resource_picture').should be_true
+ end
+ it '実素材を含んでいる' do
+ r = OriginalPicture.mylist(@artist).to_json OriginalPicture.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ i.has_key?('pictures').should be_true
end
end