1 # -*- encoding: utf-8 -*-
5 describe OriginalPicture do
7 @admin = FactoryGirl.create :admin
8 @user = FactoryGirl.create( :user_yas)
9 @author = FactoryGirl.create :author, :user_id => @user.id
10 @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
11 @other_user = FactoryGirl.create( :user_yas)
12 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
13 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
14 @sp = FactoryGirl.create :system_picture
15 @lg = FactoryGirl.create :license_group
16 @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
21 @op = FactoryGirl.build :original_picture, :artist_id => @artist.id
24 context 'オーソドックスなデータのとき' do
26 @op.ext = 'png' #リストにない拡張子は通らないし
37 @op.filesize = 2000000
43 context 'extを検証するとき' do
46 @op.should_not be_valid
50 @op.should_not be_valid
52 it 'png,gif,jpeg以外なら失敗する' do
54 @op.should_not be_valid
57 context 'widthを検証するとき' do
60 @op.should_not be_valid
64 @op.should_not be_valid
68 @op.should_not be_valid
72 @op.should_not be_valid
75 context 'heightを検証するとき' do
78 @op.should_not be_valid
82 @op.should_not be_valid
86 @op.should_not be_valid
90 @op.should_not be_valid
93 context 'filesizeを検証するとき' do
96 @op.should_not be_valid
100 @op.should_not be_valid
104 @op.should_not be_valid
107 @op.filesize = 2000000+1
108 @op.should_not be_valid
111 context 'artist_idを検証するとき' do
114 @op.should_not be_valid
118 @op.should_not be_valid
120 it '存在する絵師でなければ失敗する' do
122 @op.should_not be_valid
125 context 'md5を検証するとき' do
128 @op.should_not be_valid
132 @op.should_not be_valid
136 @op.should_not be_valid
141 describe 'デフォルト値補充に於いて' do
143 @op = FactoryGirl.build :original_picture, :artist_id => @artist.id
148 describe '上書き補充に於いて' do
150 @op = FactoryGirl.build :original_picture, :artist_id => nil
151 @op.overwrite @artist
152 @op.artist_id.should eq @artist.id
156 describe '作者判定に於いて' do
158 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
160 context 'パラメータが作家のとき' do
162 @op.own?(@author).should == true
165 @op.own?(@other_author).should == false
168 context 'パラメータが絵師のとき' do
170 @op.own?(@artist).should == true
173 @op.own?(@other_artist).should == false
178 @op.own?(nil).should == false
183 describe '閲覧許可に於いて' do
185 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
187 it '検査対象が管理者のとき、許可を返す' do
188 OriginalPicture.any_instance.stub(:own?).and_return(false)
189 r = @op.visible?(@admin)
192 it '所持判定を問い合わせ、自分の原画なら許可する' do
193 OriginalPicture.any_instance.stub(:own?).and_return(true)
194 r = @op.visible?(@artist)
198 OriginalPicture.any_instance.stub(:own?).and_return(false)
199 r = @op.visible?(@artist)
204 describe 'ファイル名に於いて' do
206 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
208 it 'id+拡張子のフォーマットで返す' do
210 r.should eq "#{@op.id}.png"
214 describe 'MimeTypeに於いて' do
216 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
218 it 'image/拡張子のフォーマットで返す' do
220 r.should eq "image/png"
224 describe 'ファイルのurlに於いて' do
226 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
227 OriginalPicture.any_instance.stub(:filename).and_return('3.gif')
229 it 'ファイル名取得を依頼している' do
230 OriginalPicture.any_instance.should_receive(:filename).exactly(1)
233 it '/original_pictures/3.gifのフォーマットで返す' do
235 r.should eq "/original_pictures/3.gif"
239 describe 'サムネイル画像タグオプションに於いて' do
241 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
242 OriginalPicture.any_instance.stub(:url).and_return('/original_pictures/3.gif')
243 PettanImager.stub(:thumbnail_size).with(any_args).and_return([40, 30])
245 it 'サムネイル画像の幅高さ取得を依頼している' do
246 PettanImager.should_receive(:thumbnail_size).with(any_args).exactly(1)
250 r = @op.tmb_opt_img_tag
251 r.is_a?(Hash).should be_true
254 r = @op.tmb_opt_img_tag
255 r.has_key?(:src).should be_true
256 r[:src].should eq '/original_pictures/3.gif'
258 it 'widthキーを含んでいる' do
259 r = @op.tmb_opt_img_tag
260 r.has_key?(:width).should be_true
261 r[:width].should eq 40
263 it 'heightキーを含んでいる' do
264 r = @op.tmb_opt_img_tag
265 r.has_key?(:height).should be_true
266 r[:height].should eq 30
270 describe '画像タグオプションに於いて' do
272 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
273 OriginalPicture.any_instance.stub(:url).and_return('/original_pictures/3.gif')
277 r.is_a?(Hash).should be_true
281 r.has_key?(:src).should be_true
282 r[:src].should eq '/original_pictures/3.gif'
284 it 'widthキーを含んでいる' do
286 r.has_key?(:width).should be_true
287 r[:width].should eq @op.width
289 it 'heightキーを含んでいる' do
291 r.has_key?(:height).should be_true
292 r[:height].should eq @op.height
296 describe '未公開に於いて' do
298 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
300 context '実素材がゼロのとき' do
306 context '実素材がゼロではないとき' do
308 @p = FactoryGirl.create :picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id
315 describe '停止中に於いて' do
317 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
319 context '未公開ではないが、素材がないとき' do
321 @p = FactoryGirl.create :picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id
332 context '未公開ではなく、素材もあるとき' do
334 @p = FactoryGirl.create :picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id
335 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id, :picture_id => @p.id
342 describe 'ライセンス待ちに於いて' do
344 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
346 context '未公開ではなく、素材もあるが、原画の更新日時が実素材のheadのそれより後のとき' do
348 @p = FactoryGirl.create :picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id, :updated_at => Time.now - 1000
349 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id, :picture_id => @p.id
360 context '未公開ではないが、素材がないとき' do
362 @p = FactoryGirl.create :picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id
367 context '未公開ではなく、素材もあり、実素材のheadの更新日時が原画のそれより後のとき' do
369 @p = FactoryGirl.create :picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id, :updated_at => Time.now + 1000
370 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id, :picture_id => @p.id
377 describe '公開中に於いて' do
379 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
381 context '未公開ではなく、素材もあり、実素材のheadの更新日時が原画のそれより後のとき' do
383 @p = FactoryGirl.create :picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id, :updated_at => Time.now + 1000
384 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id, :picture_id => @p.id
395 context '未公開ではないが、素材がないとき' do
397 @p = FactoryGirl.create :picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id
402 context '未公開ではなく、素材もあるが、原画の更新日時が実素材のheadのそれより後のとき' do
404 @p = FactoryGirl.create :picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id, :updated_at => Time.now - 1000
405 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id, :picture_id => @p.id
412 describe '一覧取得に於いて' do
414 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
416 context 'page補正について' do
417 it '文字列から数値に変換される' do
418 OriginalPicture.page('8').should eq 8
421 OriginalPicture.page().should eq 1
424 OriginalPicture.page('0').should eq 1
427 context 'page_size補正について' do
428 it '文字列から数値に変換される' do
429 OriginalPicture.page_size('7').should eq 7
431 it 'nilの場合はOriginalPicture.default_page_sizeになる' do
432 OriginalPicture.page_size().should eq OriginalPicture.default_page_size
434 it '0以下の場合はOriginalPicture.default_page_sizeになる' do
435 OriginalPicture.page_size('0').should eq OriginalPicture.default_page_size
437 it 'OriginalPicture.max_page_sizeを超えた場合はOriginalPicture.max_page_sizeになる' do
438 OriginalPicture.page_size('1000').should eq OriginalPicture.max_page_size
442 describe '一覧取得オプションに於いて' do
443 it 'includeキーを含んでいる' do
444 r = OriginalPicture.list_opt
445 r.has_key?(:include).should be_true
448 r = OriginalPicture.list_opt[:include]
449 r.should have(2).items
452 r = OriginalPicture.list_opt[:include]
453 r.has_key?(:resource_picture).should be_true
456 r = OriginalPicture.list_opt[:include]
457 r.has_key?(:pictures).should be_true
460 describe 'json一覧出力オプションに於いて' do
462 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
463 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
464 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
465 @sbt = FactoryGirl.create :speech_balloon_template
466 @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
467 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
468 @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
471 r = OriginalPicture.mylist(@artist).to_json OriginalPicture.list_json_opt
474 i.has_key?('resource_picture').should be_true
477 r = OriginalPicture.mylist(@artist).to_json OriginalPicture.list_json_opt
480 i.has_key?('pictures').should be_true
484 describe '自分のコミック一覧取得に於いて' do
486 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
488 context 'つつがなく終わるとき' do
489 it '一覧取得オプションを利用している' do
490 OriginalPicture.stub(:list_opt).with(any_args).and_return({})
491 OriginalPicture.should_receive(:list_opt).with(any_args).exactly(1)
492 r = OriginalPicture.mylist @artist
496 r = OriginalPicture.mylist @artist
500 nc = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 100
501 r = OriginalPicture.mylist @artist
502 r.should eq [nc, @op]
504 it '他人のコミックはxxxでも含まない' do
505 nc = FactoryGirl.create :original_picture, :artist_id => @other_artist.id
506 r = OriginalPicture.mylist @artist
509 it '自分のコミックはxxxでも含んでいる' do
510 nc = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 100
511 r = OriginalPicture.mylist @artist
512 r.should eq [nc, @op]
514 context 'DBに5件あって1ページの件数を2件に変えたとして' do
516 @op2 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 100
517 @op3 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 200
518 @op4 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 300
519 @op5 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 400
522 r = OriginalPicture.mylist @artist, 1, 2
523 r.should have(2).items
525 it 'page=1なら末尾2件を返す' do
527 r = OriginalPicture.mylist @artist, 1, 2
528 r.should eq [@op5, @op4]
530 it 'page=2なら中間2件を返す' do
531 r = OriginalPicture.mylist @artist, 2, 2
532 r.should eq [@op3, @op2]
534 it 'page=3なら先頭1件を返す' do
535 r = OriginalPicture.mylist @artist, 3, 2
539 context 'DBに5件あって1ページの件数を0件に変えたとして' do
541 @op2 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 100
542 @op3 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 200
543 @op4 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 300
544 @op5 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 400
545 OriginalPicture.stub(:default_page_size).and_return(2)
548 r = OriginalPicture.mylist @artist, 5, 0
549 r.should have(5).items
554 describe '更新履歴一覧取得に於いて' do
556 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
557 @p = FactoryGirl.create :picture, :artist_id => @artist.id, :license_id => @license.id, :revision => 0,
558 :original_picture_id => @op.id
559 @op2 = FactoryGirl.create :original_picture, :artist_id => @artist.id
565 it '他の原画の実素材は含んでいない' do
566 @p2 = FactoryGirl.create :picture, :artist_id => @artist.id, :license_id => @license.id, :revision => 0,
567 :original_picture_id => @op2.id
571 it 'revisionで並んでいる' do
572 @p2 = FactoryGirl.create :picture, :artist_id => @artist.id, :license_id => @license.id, :revision => 1,
573 :original_picture_id => @op.id
575 r.should eq [@p2, @p]
579 describe '単体取得に於いて' do
581 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
583 context 'つつがなく終わるとき' do
584 it '単体取得オプションを利用している' do
585 OriginalPicture.stub(:show_opt).with(any_args).and_return({})
586 OriginalPicture.should_receive(:show_opt).with(any_args).exactly(1)
587 r = OriginalPicture.show @op.id, @artist
589 it '閲覧許可を問い合わせている' do
590 OriginalPicture.any_instance.stub(:visible?).with(any_args).and_return(true)
591 OriginalPicture.any_instance.should_receive(:visible?).with(any_args).exactly(1)
592 r = OriginalPicture.show @op.id, @artist
596 pic = OriginalPicture.show @op.id, @artist
599 context '他人の原画を開こうとしたとき' do
600 it '403Forbidden例外を返す' do
601 OriginalPicture.any_instance.stub(:visible?).and_return(false)
603 pic = OriginalPicture.show @op.id, @other_artist
604 }.should raise_error(ActiveRecord::Forbidden)
607 context '存在しない原画を開こうとしたとき' do
608 it '404RecordNotFound例外を返す' do
610 pic = OriginalPicture.show 0, @artist
611 }.should raise_error(ActiveRecord::RecordNotFound)
615 describe '編集取得に於いて' do
617 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
619 context 'つつがなく終わるとき' do
620 it '単体取得オプションを利用している' do
621 OriginalPicture.stub(:show_opt).with(any_args).and_return({})
622 OriginalPicture.should_receive(:show_opt).with(any_args).exactly(1)
623 r = OriginalPicture.edit @op.id, @artist
625 it '所持判定を問い合わせている' do
626 OriginalPicture.any_instance.stub(:own?).with(any_args).and_return(true)
627 OriginalPicture.any_instance.should_receive(:own?).with(any_args).exactly(1)
628 r = OriginalPicture.edit @op.id, @artist
632 pic = OriginalPicture.edit @op.id, @artist
635 context '他人の原画を開こうとしたとき' do
636 it '403Forbidden例外を返す' do
637 OriginalPicture.any_instance.stub(:own?).and_return(false)
639 r = OriginalPicture.edit @op.id, @other_artist
640 }.should raise_error(ActiveRecord::Forbidden)
643 context '存在しない原画を開こうとしたとき' do
644 it '404RecordNotFound例外を返す' do
646 r = OriginalPicture.edit 0, @artist
647 }.should raise_error(ActiveRecord::RecordNotFound)
651 describe '単体取得オプションに於いて' do
652 it 'includeキーを含んでいる' do
653 r = OriginalPicture.show_opt
654 r.has_key?(:include).should be_true
657 r = OriginalPicture.show_opt[:include]
658 r.should have(2).items
661 r = OriginalPicture.show_opt[:include]
662 r.has_key?(:resource_picture).should be_true
665 r = OriginalPicture.show_opt[:include]
666 r.has_key?(:pictures).should be_true
669 describe 'json単体出力オプションに於いて' do
671 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
672 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
673 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
674 @sbt = FactoryGirl.create :speech_balloon_template
675 @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
676 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
677 @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
680 r = OriginalPicture.show(@op.id, @artist).to_json OriginalPicture.show_json_opt
683 i.has_key?('resource_picture').should be_true
686 r = OriginalPicture.show(@op.id, @artist).to_json OriginalPicture.show_json_opt
689 i.has_key?('pictures').should be_true
692 describe '作成・更新に於いて' do
694 @op = FactoryGirl.build :original_picture, :artist_id => @artist.id
695 @imager = ImagerTest.load "abc\ndef\nghi"
699 #すべての処理が正常パターンで通過すれば、一番深い分岐まで通る。
700 #それで外部のメソッド呼び出しだけに着目してテストする。
701 OriginalPicture.any_instance.stub(:save).with(any_args).and_return(true)
702 PictureIO.original_picture_io.stub(:put).with(any_args).and_return(true)
704 it '自身に属性をセットしている' do
705 OriginalPicture.any_instance.should_receive(:attributes=).exactly(1)
709 OriginalPicture.any_instance.should_receive(:save).exactly(1)
712 it 'PictureIoに画像データの保存を依頼している' do
713 PictureIO.original_picture_io.should_receive(:put).with(any_args).exactly(1)
717 context 'つつがなく終わるとき' do
720 it '自身に属性をセットしている' do
722 @op.width.should eq 3
723 @op.height.should eq 3
724 @op.filesize.should eq 9
726 it '原画モデルが作成されている' do
729 }.should change OriginalPicture, :count
733 OriginalPicture.find(@op).should_not be_nil
736 @op.store(@imager).should eq true
739 #以下から例外ケース。処理先頭から失敗させていく
740 context 'imagerが初期化に失敗したとき' do
744 @op.store(false).should be_false
746 it '自身の保存は呼ばれていない' do
747 OriginalPicture.any_instance.should_not_receive(:save)
750 it '全体エラーメッセージがセットされている' do
753 }.should change(@op.errors[:base], :count)
756 context '自身の保存に失敗したとき' do
758 OriginalPicture.any_instance.stub(:save).with(any_args).and_return(false)
761 @op.store(@imager).should be_false
765 @op.should be_a_new OriginalPicture
767 it '原画の保存は呼ばれていない' do
768 PictureIO::LocalPicture.any_instance.should_not_receive(:put)
771 context '原画の保存に失敗したとき' do
773 OriginalPicture.any_instance.stub(:save).with(any_args).and_return(true)
774 PictureIO.original_picture_io.stub(:put).with(any_args).and_raise(PictureIO::Error)
777 @op.store(@imager).should be_false
781 @op.should be_a_new OriginalPicture
783 it '全体エラーメッセージがセットされている' do
786 }.should change(@op.errors[:base], :count)
792 describe 'エクスポートに於いて' do
794 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
795 @p = FactoryGirl.create :picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id, :revision => 0
796 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id, :picture_id => @p.id
798 @other_op = FactoryGirl.create :original_picture, :artist_id => @other_artist.id
800 context 'つつがなく終わるとき' do
801 it 'ライセンスグループに依頼してリストを取得している' do
802 LicenseGroup.stub(:list).with(any_args).and_return([@lg])
803 LicenseGroup.should_receive(:list).with(any_args).exactly(1)
804 r = OriginalPicture.export(@artist)
806 it '原画に依頼してリストを取得している' do
807 OriginalPicture.stub(:list).with(any_args).and_return([@op])
808 OriginalPicture.should_receive(:list).with(any_args).exactly(1)
809 r = OriginalPicture.export(@artist)
812 r = OriginalPicture.export(@artist)
813 r.is_a?(Hash).should be_true
815 it 'Hashはライセンスグループを含んでいる' do
816 r = OriginalPicture.export(@artist)
817 r.include?(:license_groups).should be_true
819 it 'Hashは原画を含んでいる' do
820 r = OriginalPicture.export(@artist)
821 r.include?(:original_pictures).should be_true
823 #素材がライセンスされていないケースもある
824 it 'Hashの原画は素材を含んでいる' do
825 r = OriginalPicture.export(@artist)
826 r[:original_pictures].first.resource_picture.should_not be_nil
828 it 'Hashの原画は実素材を含んでいる' do
829 r = OriginalPicture.export(@artist)
830 r[:original_pictures].first.pictures.should be_nil
833 context '実データ単体のとき' do
834 it 'ライセンスは配列構造になっている' do
835 r = OriginalPicture.export(@artist)
836 r[:license_groups].is_a?(Array).should be_true
839 r = OriginalPicture.export(@artist)
840 r[:license_groups].size.should eq 1
841 r[:license_groups].first.should eq @lg
843 it '原画は配列構造になっている' do
844 r = OriginalPicture.export(@artist)
845 r[:original_pictures].is_a?(Array).should be_true
848 r = OriginalPicture.export(@artist)
849 r[:original_pictures].size.should eq 1
850 r[:original_pictures].first.should eq @op
852 it '原画に素材が関連付いている' do
853 r = OriginalPicture.export(@artist)
854 i = r[:original_pictures].first
855 i.resource_picture.should eq @rp
857 it '原画に実素材が関連付いている' do
858 r = OriginalPicture.export(@artist)
859 i = r[:original_pictures].first
860 i.picture.should eq @p
863 context '実データ複数のとき' do
865 @lg2 = FactoryGirl.create :license_group, :name => 'export test', :url => 'http://export.test/'
866 @license2 = FactoryGirl.create :license, :license_group_id => @lg2.id, :system_picture_id => @sp.id, :name => 'export test license', :url => 'http://export.test/license'
867 @op2 = FactoryGirl.create :original_picture, :artist_id => @artist.id
868 @p2 = FactoryGirl.create :picture, :artist_id => @artist.id, :original_picture_id => @op2.id, :license_id => @license2.id, :revision => 0
869 @rp2 = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :original_picture_id => @op2.id, :license_id => @license2.id, :picture_id => @p2.id
871 it 'ライセンスは配列構造になっている' do
872 r = OriginalPicture.export(@artist)
873 r[:license_groups].is_a?(Array).should be_true
876 r = OriginalPicture.export(@artist)
877 r[:license_groups].size.should eq 2
878 r[:license_groups].first.should eq @lg
879 r[:license_groups].last.should eq @lg2
881 it '原画は配列構造になっている' do
882 r = OriginalPicture.export(@artist)
883 r[:original_pictures].is_a?(Array).should be_true
886 r = OriginalPicture.export(@artist)
887 r[:original_pictures].size.should eq 2
888 r[:original_pictures].first.should eq @op
889 r[:original_pictures].last.should eq @op2
891 it '原画に素材が関連付いている' do
892 r = OriginalPicture.export(@artist)
893 i = r[:original_pictures].first
894 i.resource_picture.should eq @rp
895 i2 = r[:original_pictures].last
896 i2.resource_picture.should eq @rp2
898 it '原画に実素材が関連付いている' do
899 r = OriginalPicture.export(@artist)
900 i = r[:original_pictures].first
901 i.picture.should eq @p
902 i2 = r[:original_pictures].last
903 i2.picture.should eq @p2
908 describe 'エクスポートオプションに於いて' do
911 describe 'インポートに於いて' do
913 @imports = {:licenses => {}, :artist_id => @artist.id}
915 context '事前チェックしておく' do