describe '作者判定に於いて' do
before do
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
+ end
+ context 'パラメータが作家のとき' do
+ it '自作の原画ならyes' do
+ @op.own?(@author).should == true
+ end
+ it '他人のならno' do
+ @op.own?(@other_author).should == false
+ end
end
- it '自作の原画ならyes' do
- op = FactoryGirl.create :original_picture, :artist_id => @artist.id
- op.own?(@artist).should == true
+ context 'パラメータが絵師のとき' do
+ it '自作の原画ならyes' do
+ @op.own?(@artist).should == true
+ end
+ it '他人のならno' do
+ @op.own?(@other_artist).should == false
+ end
end
- it '他人のならno' do
- op = FactoryGirl.create :original_picture, :artist_id => @other_artist.id
- op.own?(@artist).should == false
+ context 'それ以外のとき' do
+ it 'no' do
+ @op.own?(nil).should == false
+ end
end
end
before do
@op = FactoryGirl.create :original_picture, :artist_id => @artist.id
OriginalPicture.any_instance.stub(:url).and_return('/original_pictures/3.gif')
- ResourcePicture.stub(:fix_size_both).with(any_args).and_return([40, 30])
+ PettanImager.stub(:thumbnail_size).with(any_args).and_return([40, 30])
end
it 'サムネイル画像の幅高さ取得を依頼している' do
- ResourcePicture.should_receive(:fix_size_both).with(any_args).exactly(1)
+ PettanImager.should_receive(:thumbnail_size).with(any_args).exactly(1)
@op.opt_img_tag
end
it '戻り値はHashで返す' do
end
end
end
- describe 'list関連テーブルプションに於いて' do
+ describe '一覧取得オプションに於いて' do
it 'includeキーを含んでいる' do
r = OriginalPicture.list_opt
r.has_key?(:include).should be_true
end
end
describe 'json一覧出力オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = OriginalPicture.list_json_opt
- r.has_key?(:include).should be_true
- end
- it '2つの項目を含んでいる' do
- r = OriginalPicture.list_json_opt[:include]
- r.should have(2).items
+ before do
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
+ @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id\r
+ @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id\r
+ @sbt = FactoryGirl.create :speech_balloon_template\r
+ @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.list_json_opt[:include]
- r.has_key?(:resource_picture).should be_true
+ 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.list_json_opt[:include]
- r.has_key?(:pictures).should be_true
+ 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
@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)\r
end
it '通常は全件(5件)を返す' do
r = OriginalPicture.mylist @artist, 5, 0
end
end
end
- describe 'å\8d\98ä½\93å\87ºå\8a\9bオプションに於いて' do
+ describe 'å\8d\98ä½\93å\8f\96å¾\97オプションに於いて' do
it 'includeキーを含んでいる' do
r = OriginalPicture.show_opt
r.has_key?(:include).should be_true
end
end
describe 'json単体出力オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = OriginalPicture.show_json_opt
- r.has_key?(:include).should be_true
- end
- it '2つの項目を含んでいる' do
- r = OriginalPicture.show_json_opt[:include]
- r.should have(2).items
+ before do
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
+ @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id\r
+ @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id\r
+ @sbt = FactoryGirl.create :speech_balloon_template\r
+ @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.show_json_opt[:include]
- r.has_key?(:resource_picture).should be_true
+ r = OriginalPicture.show(@op.id, @artist).to_json OriginalPicture.show_json_opt
+ j = JSON.parse r
+ i = j
+ i.has_key?('resource_picture').should be_true
end
it '実素材を含んでいる' do
- r = OriginalPicture.show_json_opt[:include]
- r.has_key?(:pictures).should be_true
+ r = OriginalPicture.show(@op.id, @artist).to_json OriginalPicture.show_json_opt
+ j = JSON.parse r
+ i = j
+ i.has_key?('pictures').should be_true
end
end
describe '作成・更新に於いて' do