1 # -*- encoding: utf-8 -*-
\r
2 require 'spec_helper'
\r
6 @admin = FactoryGirl.create :admin
\r
7 @sp = FactoryGirl.create :system_picture
\r
8 @lg = FactoryGirl.create :license_group
\r
9 @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
\r
10 @color = FactoryGirl.create :color
\r
11 @user = FactoryGirl.create( :user_yas)
\r
12 @author = FactoryGirl.create :author, :user_id => @user.id
\r
13 @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
\r
14 @other_user = FactoryGirl.create( :user_yas)
\r
15 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
\r
16 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
\r
17 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
\r
18 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
\r
19 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
\r
20 @sbt = FactoryGirl.create :speech_balloon_template
\r
23 describe '検証に於いて' do
\r
25 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
28 context 'オーソドックスなデータのとき' do
\r
37 @panel.should be_valid
\r
40 @panel.width = 99999
\r
41 @panel.height = 99999
\r
42 @panel.border = 99999
\r
46 @panel.publish = 99999
\r
47 @panel.should be_valid
\r
51 context 'widthを検証するとき' do
\r
54 @panel.should_not be_valid
\r
58 @panel.should_not be_valid
\r
62 @panel.should_not be_valid
\r
66 @panel.should_not be_valid
\r
69 context 'heightを検証するとき' do
\r
72 @panel.should_not be_valid
\r
76 @panel.should_not be_valid
\r
80 @panel.should_not be_valid
\r
84 @panel.should_not be_valid
\r
87 context 'borderを検証するとき' do
\r
90 @panel.should_not be_valid
\r
94 @panel.should_not be_valid
\r
97 @panel.border = '-1'
\r
98 @panel.should_not be_valid
\r
102 @panel.should be_valid
\r
105 context 'xを検証するとき' do
\r
106 it '数値でなければ失敗する' do
\r
108 @panel.should_not be_valid
\r
112 @panel.should be_valid
\r
116 @panel.should be_valid
\r
119 context 'yを検証するとき' do
\r
120 it '数値でなければ失敗する' do
\r
122 @panel.should_not be_valid
\r
126 @panel.should be_valid
\r
130 @panel.should be_valid
\r
133 context 'zを検証するとき' do
\r
134 it '数値でなければ失敗する' do
\r
136 @panel.should_not be_valid
\r
140 @panel.should_not be_valid
\r
144 @panel.should_not be_valid
\r
147 context 'author_idを検証するとき' do
\r
149 @panel.author_id = nil
\r
150 @panel.should_not be_valid
\r
152 it '数値でなければ失敗する' do
\r
153 @panel.author_id = 'a'
\r
154 @panel.should_not be_valid
\r
156 it '存在する作家でなければ失敗する' do
\r
157 @panel.author_id = 0
\r
158 @panel.should_not be_valid
\r
161 context '公開フラグを検証するとき' do
\r
162 it '数値でなければ失敗する' do
\r
163 @panel.publish = 'a'
\r
164 @panel.should_not be_valid
\r
167 context '全体を検証するとき' do
\r
169 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
174 describe 'デフォルト値補充に於いて' do
\r
176 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
178 it 'borderは2を補充する' do
\r
179 @panel.border = nil
\r
180 @panel.supply_default
\r
181 @panel.border.should eq 2
\r
183 it 'publishは0を補充する' do
\r
184 @panel.publish = nil
\r
185 @panel.supply_default
\r
186 @panel.publish.should eq 0
\r
190 describe '上書き補充に於いて' do
\r
192 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
194 context 'author_idを補充' do
\r
195 it 'ログイン中の作家idを補充する' do
\r
196 @panel.author_id = nil
\r
197 @panel.overwrite @author
\r
198 @panel.author_id.should eq @author.id
\r
204 describe '作者判定に於いて' do
\r
206 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
209 @panel.own?(@author).should == true
\r
212 @panel.own?(@other_author).should == false
\r
214 it 'パラメータが作家でないならno' do
\r
215 @panel.own?(nil).should == false
\r
219 describe '閲覧許可に於いて' do
\r
221 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
223 context '検査対象がnil(ゲスト)のとき' do
\r
224 context 'クローズドモードのとき' do
\r
226 MagicNumber['run_mode'] = 1
\r
229 r = @panel.visible?(nil)
\r
233 context 'オープンモードのとき' do
\r
235 MagicNumber['run_mode'] = 0
\r
238 Panel.any_instance.stub(:publish?).and_return(true)
\r
239 r = @panel.visible?(nil)
\r
242 it '非公開コマなら許可しない' do
\r
243 Panel.any_instance.stub(:publish?).and_return(false)
\r
244 r = @panel.visible?(nil)
\r
249 context '検査対象が作家のとき' do
\r
250 it '自分のコマなら許可する' do
\r
251 Panel.any_instance.stub(:own?).and_return(true)
\r
252 Panel.any_instance.stub(:publish?).and_return(true)
\r
253 r = @panel.visible?(@author)
\r
256 it '他人の非公開コマなら許可しない' do
\r
257 Panel.any_instance.stub(:own?).and_return(false)
\r
258 Panel.any_instance.stub(:publish?).and_return(false)
\r
259 r = @panel.visible?(@author)
\r
262 it '他人のコマでも公開なら許可する' do
\r
263 Panel.any_instance.stub(:own?).and_return(false)
\r
264 Panel.any_instance.stub(:publish?).and_return(true)
\r
265 r = @panel.visible?(@author)
\r
269 context '検査対象がそれ以外のとき' do
\r
271 r = @panel.visible?(@admin)
\r
277 describe '一覧取得に於いて' do
\r
279 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
281 context 'page補正について' do
\r
282 it '文字列から数値に変換される' do
\r
283 Panel.page('8').should eq 8
\r
285 it 'nilの場合は1になる' do
\r
286 Panel.page().should eq 1
\r
288 it '0以下の場合は1になる' do
\r
289 Panel.page('0').should eq 1
\r
292 context 'page_size補正について' do
\r
293 it '文字列から数値に変換される' do
\r
294 Panel.page_size('7').should eq 7
\r
296 it 'nilの場合はPanel.default_page_sizeになる' do
\r
297 Panel.page_size().should eq Panel.default_page_size
\r
299 it '0以下の場合はPanel.default_page_sizeになる' do
\r
300 Panel.page_size('0').should eq Panel.default_page_size
\r
302 it 'Panel.max_page_sizeを超えた場合はPanel.max_page_sizeになる' do
\r
303 Panel.page_size('1000').should eq Panel.max_page_size
\r
308 r.should eq [@panel]
\r
311 #公開コミックは(他人のコミックであっても)含んでいる
\r
312 npl = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 100
\r
314 r.should eq [npl, @panel]
\r
316 it '非公開のコマ(自分のコマであっても)は含まない' do
\r
317 npl = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0
\r
319 r.should eq [@panel]
\r
321 context 'DBに5件あって1ページの件数を2件に変えたとして' do
\r
323 @npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100
\r
324 @npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200
\r
325 @npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300
\r
326 @npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400
\r
327 Panel.stub(:default_page_size).and_return(2)
\r
331 pl.should have(2).items
\r
333 it 'page=1なら末尾2件を返す' do
\r
336 pl.should eq [@npl5, @npl4]
\r
338 it 'page=2なら中間2件を返す' do
\r
340 pl.should eq [@npl3, @npl2]
\r
342 it 'page=3なら先頭1件を返す' do
\r
344 pl.should eq [@panel]
\r
347 context 'DBに5件あって1ページの件数を2件に変えたとして' do
\r
349 @npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100
\r
350 @npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200
\r
351 @npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300
\r
352 @npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400
\r
353 Panel.stub(:default_page_size).and_return(2)
\r
355 it '件数0は全件(5件)を返す' do
\r
356 r = Panel.list 5, 0
\r
357 r.should have(5).items
\r
361 describe '一覧取得オプションに於いて' do
\r
362 it 'includeキーを含んでいる' do
\r
364 r.has_key?(:include).should be_true
\r
366 it '6つの項目を含んでいる' do
\r
367 r = Panel.list_opt[:include]
\r
368 r.should have(6).items
\r
371 r = Panel.list_opt[:include]
\r
372 r.has_key?(:panel_pictures).should be_true
\r
374 it 'コマ絵は実素材を含んでいる' do
\r
375 r = Panel.list_opt[:include]
\r
376 r[:panel_pictures].has_key?(:picture).should be_true
\r
378 it '実素材は絵師を含んでいる' do
\r
379 r = Panel.list_opt[:include]
\r
380 r[:panel_pictures][:picture].has_key?(:artist).should be_true
\r
382 it '実素材はライセンスを含んでいる' do
\r
383 r = Panel.list_opt[:include]
\r
384 r[:panel_pictures][:picture].has_key?(:license).should be_true
\r
387 r = Panel.list_opt[:include]
\r
388 r.has_key?(:speech_balloons).should be_true
\r
390 it 'フキダシはフキダシ枠を含んでいる' do
\r
391 r = Panel.list_opt[:include]
\r
392 r[:speech_balloons].has_key?(:balloons).should be_true
\r
394 it 'フキダシはセリフを含んでいる' do
\r
395 r = Panel.list_opt[:include]
\r
396 r[:speech_balloons].has_key?(:speeches).should be_true
\r
399 r = Panel.list_opt[:include]
\r
400 r.has_key?(:ground_pictures).should be_true
\r
402 it '景色画像は実素材を含んでいる' do
\r
403 r = Panel.list_opt[:include]
\r
404 r[:ground_pictures].has_key?(:picture).should be_true
\r
406 it '実素材は絵師を含んでいる' do
\r
407 r = Panel.list_opt[:include]
\r
408 r[:ground_pictures][:picture].has_key?(:artist).should be_true
\r
410 it '実素材はライセンスを含んでいる' do
\r
411 r = Panel.list_opt[:include]
\r
412 r[:ground_pictures][:picture].has_key?(:license).should be_true
\r
415 r = Panel.list_opt[:include]
\r
416 r.has_key?(:ground_colors).should be_true
\r
418 it '間接色は色を含んでいる' do
\r
419 r = Panel.list_opt[:include]
\r
420 r[:ground_colors].has_key?(:color).should be_true
\r
423 r = Panel.list_opt[:include]
\r
424 r.has_key?(:panel_colors).should be_true
\r
427 r = Panel.list_opt[:include]
\r
428 r.has_key?(:author).should be_true
\r
431 describe 'json一覧出力オプションに於いて' do
\r
434 describe '自分のコマ一覧取得に於いて' do
\r
436 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
439 pl = Panel.mylist @author
\r
440 pl.should eq [@panel]
\r
443 npl = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100
\r
444 pl = Panel.mylist @author
\r
445 pl.should eq [npl, @panel]
\r
447 it '他人のコマは公開でも含まない' do
\r
448 npl = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
\r
449 pl = Panel.mylist @author
\r
450 pl.should eq [@panel]
\r
452 it '自分のコマは非公開でも含んでいる' do
\r
453 npl = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0, :updated_at => Time.now + 100
\r
454 pl = Panel.mylist @author
\r
455 pl.should eq [npl, @panel]
\r
457 context 'DBに5件あって1ページの件数を2件に変えたとして' do
\r
459 @npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100
\r
460 @npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200
\r
461 @npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300
\r
462 @npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400
\r
465 pl = Panel.list 1, 2
\r
466 pl.should have(2).items
\r
468 it 'page=1なら末尾2件を返す' do
\r
470 pl = Panel.mylist @author, 1, 2
\r
471 pl.should eq [@npl5, @npl4]
\r
473 it 'page=2なら中間2件を返す' do
\r
474 pl = Panel.mylist @author, 2, 2
\r
475 pl.should eq [@npl3, @npl2]
\r
477 it 'page=3なら先頭1件を返す' do
\r
478 pl = Panel.mylist @author, 3, 2
\r
479 pl.should eq [@panel]
\r
482 context 'DBに5件あって1ページの件数を0件に変えたとして' do
\r
484 @npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100
\r
485 @npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200
\r
486 @npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300
\r
487 @npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400
\r
488 Author.stub(:default_panel_page_size).and_return(2)
\r
490 it '通常は全件(5件)を返す' do
\r
491 r = Panel.mylist @author, 5, 0
\r
492 r.should have(5).items
\r
497 describe '単体取得に於いて' do
\r
499 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
501 context 'つつがなく終わるとき' do
\r
502 it '単体取得オプションを利用している' do
\r
503 Panel.stub(:show_opt).with(any_args).and_return({})
\r
504 Panel.should_receive(:show_opt).with(any_args).exactly(1)
\r
505 r = Panel.show @panel.id, @author
\r
507 it '閲覧許可を問い合わせている' do
\r
508 Panel.any_instance.stub(:visible?).with(any_args).and_return(true)
\r
509 Panel.any_instance.should_receive(:visible?).with(any_args).exactly(1)
\r
510 r = Panel.show @panel.id, @author
\r
514 Panel.any_instance.stub(:visible?).and_return(true)
\r
515 pl = Panel.show @panel.id, @author
\r
516 pl.should eq @panel
\r
518 context '閲覧許可が出なかったとき' do
\r
519 it '403Forbidden例外を返す' do
\r
520 Panel.any_instance.stub(:visible?).and_return(false)
\r
522 Panel.show @panel.id, @author
\r
523 }.should raise_error(ActiveRecord::Forbidden)
\r
526 context '存在しないコマを開こうとしたとき' do
\r
527 it '404RecordNotFound例外を返す' do
\r
529 Panel.show 110, @author
\r
530 }.should raise_error(ActiveRecord::RecordNotFound)
\r
534 describe '編集取得に於いて' do
\r
536 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
538 context 'つつがなく終わるとき' do
\r
539 it '単体取得オプションを利用している' do
\r
540 Panel.stub(:show_opt).with(any_args).and_return({})
\r
541 Panel.should_receive(:show_opt).with(any_args).exactly(1)
\r
542 r = Panel.edit @panel.id, @author
\r
544 it '所持判定を問い合わせている' do
\r
545 Panel.any_instance.stub(:own?).with(any_args).and_return(true)
\r
546 Panel.any_instance.should_receive(:own?).with(any_args).exactly(1)
\r
547 r = Panel.edit @panel.id, @author
\r
551 Panel.any_instance.stub(:own?).and_return(true)
\r
552 pl = Panel.edit @panel.id, @author
\r
553 pl.should eq @panel
\r
555 context '他人のコマを開こうとしたとき' do
\r
556 it '403Forbidden例外を返す' do
\r
557 Panel.any_instance.stub(:own?).and_return(false)
\r
559 Panel.edit @panel.id, @author
\r
560 }.should raise_error(ActiveRecord::Forbidden)
\r
563 context '存在しないコマを開こうとしたとき' do
\r
564 it '404RecordNotFound例外を返す' do
\r
566 Panel.edit 110, @author
\r
567 }.should raise_error(ActiveRecord::RecordNotFound)
\r
571 describe '単体取得オプションに於いて' do
\r
572 it 'includeキーを含んでいる' do
\r
574 r.has_key?(:include).should be_true
\r
576 it '6つの項目を含んでいる' do
\r
577 r = Panel.show_opt[:include]
\r
578 r.should have(6).items
\r
581 r = Panel.show_opt[:include]
\r
582 r.has_key?(:panel_pictures).should be_true
\r
584 it 'コマ絵は実素材を含んでいる' do
\r
585 r = Panel.show_opt[:include]
\r
586 r[:panel_pictures].has_key?(:picture).should be_true
\r
588 it '実素材は絵師を含んでいる' do
\r
589 r = Panel.show_opt[:include]
\r
590 r[:panel_pictures][:picture].has_key?(:artist).should be_true
\r
592 it '実素材はライセンスを含んでいる' do
\r
593 r = Panel.show_opt[:include]
\r
594 r[:panel_pictures][:picture].has_key?(:license).should be_true
\r
597 r = Panel.show_opt[:include]
\r
598 r.has_key?(:speech_balloons).should be_true
\r
600 it 'フキダシはフキダシ枠を含んでいる' do
\r
601 r = Panel.show_opt[:include]
\r
602 r[:speech_balloons].has_key?(:balloons).should be_true
\r
604 it 'フキダシはセリフを含んでいる' do
\r
605 r = Panel.show_opt[:include]
\r
606 r[:speech_balloons].has_key?(:speeches).should be_true
\r
609 r = Panel.show_opt[:include]
\r
610 r.has_key?(:ground_pictures).should be_true
\r
612 it '景色画像は実素材を含んでいる' do
\r
613 r = Panel.show_opt[:include]
\r
614 r[:ground_pictures].has_key?(:picture).should be_true
\r
616 it '実素材は絵師を含んでいる' do
\r
617 r = Panel.show_opt[:include]
\r
618 r[:ground_pictures][:picture].has_key?(:artist).should be_true
\r
620 it '実素材はライセンスを含んでいる' do
\r
621 r = Panel.show_opt[:include]
\r
622 r[:ground_pictures][:picture].has_key?(:license).should be_true
\r
625 r = Panel.show_opt[:include]
\r
626 r.has_key?(:ground_colors).should be_true
\r
628 it '間接色は色を含んでいる' do
\r
629 r = Panel.show_opt[:include]
\r
630 r[:ground_colors].has_key?(:color).should be_true
\r
633 r = Panel.show_opt[:include]
\r
634 r.has_key?(:panel_colors).should be_true
\r
637 r = Panel.show_opt[:include]
\r
638 r.has_key?(:author).should be_true
\r
641 describe 'json単体出力オプションに於いて' do
\r
643 describe 'コマ部品集合に於いて' do
\r
646 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
647 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
\r
648 @sb = @panel.speech_balloons.create(
\r
649 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
651 @gc = @panel.ground_colors.create(
\r
652 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
654 @gp = @panel.ground_pictures.create(
\r
655 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
\r
657 @pc = @panel.panel_colors.create(
\r
658 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
663 r = @panel.parts_element
\r
664 r.is_a?(Array).should be_true
\r
666 it 'コマ絵とフキダシを合わせている' do
\r
667 r = @panel.parts_element
\r
668 r.include?(@pp).should be_true
\r
669 r.include?(@sb).should be_true
\r
671 it '景色素材と景色カラーと景色カラーコードを含んでいない' do
\r
672 r = @panel.parts_element
\r
673 r.include?(@gc).should_not be_true
\r
674 r.include?(@gp).should_not be_true
\r
675 r.include?(@pc).should_not be_true
\r
678 describe 'コマ部品に於いて' do
\r
681 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
682 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
\r
683 @sb = @panel.speech_balloons.create(
\r
684 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
686 @gc = @panel.ground_colors.create(
\r
687 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
689 @gp = @panel.ground_pictures.create(
\r
690 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
\r
692 @pc = @panel.panel_colors.create(
\r
693 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
697 context 'つつがなく終わるとき' do
\r
698 it 'コマ部品集合を利用している' do
\r
699 Panel.any_instance.stub(:parts_element).with(any_args).and_return([])
\r
700 Panel.any_instance.should_receive(:parts_element).with(any_args).exactly(1)
\r
706 r.is_a?(Array).should be_true
\r
714 context 'さらに末尾にフキダシを追加したとき' do
\r
716 @sb2 = @panel.speech_balloons.create(
\r
717 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 2)
\r
725 r[2].should eq @sb2
\r
729 describe 'コマ地に於いて' do
\r
732 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
733 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
\r
734 @sb = @panel.speech_balloons.create(
\r
735 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
737 @gc = @panel.ground_colors.create(
\r
738 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
740 @gp = @panel.ground_pictures.create(
\r
741 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
\r
743 @pc = @panel.panel_colors.create(
\r
744 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
750 r.is_a?(Array).should be_true
\r
752 it '景色素材と景色カラーと景色カラーコードを合わせている' do
\r
754 r.include?(@gc).should be_true
\r
755 r.include?(@gp).should be_true
\r
756 r.include?(@pc).should be_true
\r
758 it 'コマ絵とフキダシを含んでいない' do
\r
760 r.include?(@pp).should_not be_true
\r
761 r.include?(@sb).should_not be_true
\r
764 describe 'コマ要素に於いて' do
\r
767 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
768 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
\r
769 @sb = @panel.speech_balloons.create(
\r
770 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
772 @gc = @panel.ground_colors.create(
\r
773 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
775 @gp = @panel.ground_pictures.create(
\r
776 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
\r
778 @pc = @panel.panel_colors.create(
\r
779 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
783 context 'つつがなく終わるとき' do
\r
784 it 'コマ部品を利用している' do
\r
785 Panel.any_instance.stub(:parts).with(any_args).and_return([])
\r
786 Panel.any_instance.should_receive(:parts).with(any_args).exactly(1)
\r
787 r = @panel.panel_elements
\r
790 Panel.any_instance.stub(:grounds).with(any_args).and_return([])
\r
791 Panel.any_instance.should_receive(:grounds).with(any_args).exactly(1)
\r
792 r = @panel.panel_elements
\r
796 r = @panel.panel_elements
\r
797 r.is_a?(Array).should be_true
\r
799 it 'コマ絵とフキダシを合わせている' do
\r
800 r = @panel.panel_elements
\r
801 r.include?(@pp).should be_true
\r
802 r.include?(@sb).should be_true
\r
804 it '景色素材と景色カラーと景色カラーコードを合わせている' do
\r
805 r = @panel.panel_elements
\r
806 r.include?(@gc).should be_true
\r
807 r.include?(@gp).should be_true
\r
808 r.include?(@pc).should be_true
\r
810 it 'tでソートしている[t順にソートできる部品の方が優先順位は高い。]' do
\r
811 r = @panel.panel_elements
\r
816 describe 'コマ要素のjson出力に於いて' do
\r
819 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
820 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
\r
821 @sb = @panel.speech_balloons.create(
\r
822 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
824 @gc = @panel.ground_colors.create(
\r
825 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
827 @gp = @panel.ground_pictures.create(
\r
828 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
\r
830 @pc = @panel.panel_colors.create(
\r
831 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
835 context 'つつがなく終わるとき' do
\r
837 Panel.stub(:elm_json_opt).with(@pp).and_return({})
\r
838 Panel.stub(:elm_json_opt).with(@sb).and_return({})
\r
839 Panel.stub(:elm_json_opt).with(@gp).and_return({})
\r
840 Panel.stub(:elm_json_opt).with(@gc).and_return({})
\r
841 Panel.stub(:elm_json_opt).with(@pc).and_return({})
\r
843 it 'コマ要素のjson出力オプションにコマ絵json出力オプションを依頼している' do
\r
844 Panel.should_receive(:elm_json_opt).with(@pp).exactly(1)
\r
845 r = @panel.elements
\r
847 it 'コマ要素のjson出力オプションにフキダシjson出力オプションを依頼している' do
\r
848 Panel.should_receive(:elm_json_opt).with(@sb).exactly(1)
\r
849 r = @panel.elements
\r
851 it 'コマ要素のjson出力オプションに景色素材json出力オプションを依頼している' do
\r
852 Panel.should_receive(:elm_json_opt).with(@gp).exactly(1)
\r
853 r = @panel.elements
\r
855 it 'コマ要素のjson出力オプションに景色カラーjson出力オプションを依頼している' do
\r
856 Panel.should_receive(:elm_json_opt).with(@gc).exactly(1)
\r
857 r = @panel.elements
\r
859 it 'コマ要素のjson出力オプションに景色カラーコードjson出力オプションを依頼している' do
\r
860 Panel.should_receive(:elm_json_opt).with(@pc).exactly(1)
\r
861 r = @panel.elements
\r
865 r = @panel.elements
\r
866 r.is_a?(Array).should be_true
\r
869 describe 'コマのjson出力に於いて' do
\r
872 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
873 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
\r
874 @sb = @panel.speech_balloons.create(
\r
875 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
877 @gc = @panel.ground_colors.create(
\r
878 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
880 @gp = @panel.ground_pictures.create(
\r
881 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
\r
883 @pc = @panel.panel_colors.create(
\r
884 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
888 context 'つつがなく終わるとき' do
\r
890 Panel.any_instance.stub(:elements).with(any_args).and_return({})
\r
892 it 'コマ要素のjson出力を依頼している' do
\r
893 Panel.any_instance.should_receive(:elements).with(any_args).exactly(1)
\r
894 r = @panel.panel_elements_as_json
\r
897 it 'json textを返している' do
\r
898 r = JSON.parse @panel.panel_elements_as_json
\r
899 r.is_a?(Hash).should be_true
\r
901 it 'author,コマ要素を含んでいる' do
\r
902 r = JSON.parse @panel.panel_elements_as_json
\r
903 r.has_key?('author').should be_true
\r
904 r.has_key?('elements').should be_true
\r
906 sb = r['elements'].first
\r
907 sb.has_key?('classname').should be_true
\r
908 sb.has_key?('balloons').should be_true
\r
909 sb.has_key?('speeches').should be_true
\r
913 describe 'コマリストのjson出力に於いて' do
\r
915 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
916 Panel.any_instance.stub(:panel_elements_as_json).with(any_args).and_return('{"p": 5}')
\r
918 context 'つつがなく終わるとき' do
\r
919 it 'コマのjson出力を依頼している' do
\r
920 Panel.any_instance.should_receive(:panel_elements_as_json).with(any_args).exactly(1)
\r
921 r = Panel.list_as_json_text [@panel]
\r
924 it 'json textを返している' do
\r
925 r = Panel.list_as_json_text [@panel]
\r
927 j.is_a?(Array).should be_true
\r
930 r = Panel.list_as_json_text [@panel]
\r
932 j.first.has_key?('p').should be_true
\r
936 describe 'ライセンス素材に於いて' do
\r
939 @op2 = FactoryGirl.create :original_picture, :artist_id => @artist.id
\r
940 @p2 = FactoryGirl.create :picture, :original_picture_id => @op2.id, :license_id => @license.id, :artist_id => @artist.id
\r
941 @rp2 = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op2.id, :picture_id => @p2.id
\r
942 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
943 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height, :picture_id => @p.id
\r
944 @sb = @panel.speech_balloons.create(
\r
945 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
947 @gc = @panel.ground_colors.create(
\r
948 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
950 @gp = @panel.ground_pictures.create(
\r
951 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p2.id)
\r
953 @pc = @panel.panel_colors.create(
\r
954 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
958 context '事前チェック' do
\r
960 context 'つつがなく終わるとき' do
\r
962 it '連想配列(値は実素材、キーは実素材id)を返している' do
\r
963 r = @panel.licensed_pictures
\r
964 r.is_a?(Hash).should be_true
\r
965 r.should have(2).items
\r
966 r[@pp.picture_id].should eq @p
\r
967 r[@gp.picture_id].should eq @p2
\r
971 describe '検証値収集に於いて' do
\r
972 context 'つつがなく終わるとき' do
\r
973 it '第一パラメータで指定された配列中から第二引数のカラム値を収集している' do
\r
974 elements = [[{:panel_id => 1, :a => 'a'}, {:panel_id => 2, :a => 'a'}],
\r
975 [{:panel_id => 3, :a => 'a'}, {:panel_id => 4, :a => 'a'}]]
\r
976 r = Panel.collect_element_value elements, :panel_id
\r
977 r.should eq [1, 2, 3, 4]
\r
979 it '第一パラメータで指定された配列中から第二引数のカラム値を収集している' do
\r
980 elements = [[{:t => 1, :a => 'a'}, {:t => 2, :a => 'a'}],
\r
981 [{:t => 3, :a => 'a'}, {:t => 0, :a => 'a'}]]
\r
982 r = Panel.collect_element_value elements, :t
\r
983 r.should eq [1, 2, 3, 0]
\r
987 describe 'シリアライズチェックに於いて' do
\r
988 context 'つつがなく終わるとき' do
\r
989 it '0からシリアライズされているならTrueを返す' do
\r
990 r = Panel.validate_t [0, 1, 2]
\r
993 it '見た目はシリアライズされてなくてもソート結果が無事ならtrueを返す' do
\r
994 r = Panel.validate_t [0, 2, 1]
\r
997 it '見た目はシリアライズされてなくてもソート結果が無事ならtrueを返す' do
\r
998 r = Panel.validate_t [ 2, 1, 4, 3, 0]
\r
1002 context '異常なとき' do
\r
1003 it '0から始まらないならFalseを返す' do
\r
1004 r = Panel.validate_t [1, 2, 3]
\r
1007 it '連続していないならFalseを返す' do
\r
1008 r = Panel.validate_t [0, 1, 2, 4]
\r
1011 it '連続していないならFalseを返す' do
\r
1012 r = Panel.validate_t [0, 1, 2, 4, 5]
\r
1017 describe 'tチェック単体に於いて' do
\r
1020 context 'つつがなく終わるとき' do
\r
1021 it '検証値収集を依頼している' do
\r
1022 Panel.should_receive(:collect_element_value).with(any_args).exactly(1)
\r
1023 Panel.stub(:collect_element_value).with(any_args).and_return([])
\r
1024 Panel.stub(:validate_t).with(any_args).and_return(true)
\r
1025 r = Panel.validate_element_t [], :t
\r
1027 it 'シリアライズチェック依頼している' do
\r
1028 Panel.stub(:collect_element_value).with(any_args).and_return([])
\r
1029 Panel.should_receive(:validate_t).with(any_args).exactly(1)
\r
1030 Panel.stub(:validate_t).with(any_args).and_return(true)
\r
1031 r = Panel.validate_element_t [], :t
\r
1035 describe '従属データの検証に於いて' do
\r
1036 context 'つつがなく終わるとき' do
\r
1037 it 'trueを返している' do
\r
1038 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1039 @panel.panel_pictures.build(
\r
1040 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 0)
\r
1042 @panel.panel_pictures.build(
\r
1043 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 1)
\r
1045 sb1 = @panel.speech_balloons.build(
\r
1046 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 2)
\r
1048 sb1.balloons.build(
\r
1049 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb1.id)
\r
1051 sb1.speeches.build(
\r
1052 FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb1.id)
\r
1054 sb2 = @panel.speech_balloons.build(
\r
1055 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 3)
\r
1057 sb2.balloons.build(
\r
1058 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb2.id)
\r
1060 sb2.speeches.build(
\r
1061 FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb2.id)
\r
1063 r = @panel.validate_child
\r
1067 context 'シリアライズされていないとき' do
\r
1068 it 'falseを返している' do
\r
1069 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1070 @panel.panel_pictures.build(
\r
1071 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 0)
\r
1073 @panel.panel_pictures.build(
\r
1074 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 1)
\r
1076 sb1 = @panel.speech_balloons.build(
\r
1077 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 2)
\r
1079 sb1.balloons.build(
\r
1080 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb1.id)
\r
1082 sb1.speeches.build(
\r
1083 FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb1.id)
\r
1085 sb2 = @panel.speech_balloons.build(
\r
1086 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 4)
\r
1088 sb2.balloons.build(
\r
1089 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb2.id)
\r
1091 sb2.speeches.build(
\r
1092 FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb2.id)
\r
1094 r = @panel.validate_child
\r
1099 describe '保存に於いて' do
\r
1101 @attr = FactoryGirl.attributes_for :panel
\r
1102 @panel = Panel.new
\r
1103 @panel.supply_default
\r
1105 context 'つつがなく終わるとき' do
\r
1107 Panel.any_instance.stub(:validate_child).with(any_args).and_return(true)
\r
1108 Panel.any_instance.stub(:save).with(any_args).and_return(true)
\r
1110 it 'コマモデルに上書き補充を依頼している' do
\r
1111 Panel.any_instance.should_receive(:overwrite).exactly(1)
\r
1112 r = @panel.store @attr, @author
\r
1114 it '従属データの検証を依頼している' do
\r
1115 Panel.any_instance.should_receive(:validate_child).with(any_args).exactly(1)
\r
1116 r = @panel.store @attr, @author
\r
1119 Panel.any_instance.should_receive(:save).with(any_args).exactly(1)
\r
1120 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1121 r = @panel.store @attr, @author
\r
1124 context 'つつがなく終わるとき' do
\r
1126 Panel.any_instance.stub(:validate_child).with(any_args).and_return(true)
\r
1129 r = @panel.store @attr, @author
\r
1133 Panel.any_instance.stub(:validate_child).with(any_args).and_return(true)
\r
1135 r = @panel.store @attr, @author
\r
1136 }.should change(Panel, :count)
\r
1139 context '不正なjsonデータのとき' do
\r
1142 it 'エラーメッセージがセットされている' do
\r
1143 r = @panel.store false, @author
\r
1144 @panel.errors[:base].should_not be_blank
\r
1147 context '従属データの検証に失敗したとき' do
\r
1149 Panel.any_instance.stub(:validate_child).with(any_args).and_return(false)
\r
1151 it 'エラーメッセージがセットされている' do
\r
1152 r = @panel.store @attr, @author
\r
1153 @panel.errors[:base].should_not be_blank
\r
1156 context 'カラム値がFalseしたとき' do
\r
1158 Panel.any_instance.stub(:validate_child).with(any_args).and_return(true)
\r
1160 it 'エラーメッセージがセットされている' do
\r
1161 r = @panel.store false, @author
\r
1162 @panel.errors.should_not be_empty
\r
1167 describe '削除に於いて' do
\r
1169 @comic = FactoryGirl.create :comic, :author_id => @author.id
\r
1170 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
\r
1171 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
\r
1172 @sb = @panel.speech_balloons.create(
\r
1173 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
1175 @gc = @panel.ground_colors.create(
\r
1176 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
1178 @gp = @panel.ground_pictures.create(
\r
1179 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
\r
1181 @pc = @panel.panel_colors.create(
\r
1182 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
1185 context 'つつがなく終わるとき' do
\r
1188 r = @panel.destroy_with_elements
\r
1189 }.should change(Panel, :count).by(-1)
\r
1191 r = Panel.find @panel.id
\r
1192 }.should raise_error
\r
1194 it '自身にリンクしているコマ要素をすべて削除する' do
\r
1196 r = @panel.destroy_with_elements
\r
1197 }.should change(PanelPicture, :count).by(-1)
\r
1199 r = PanelPicture.find @pp.id
\r
1200 }.should raise_error
\r
1202 it '自身にリンクしているコマ要素をすべて削除する' do
\r
1204 r = @panel.destroy_with_elements
\r
1205 }.should change(GroundPicture, :count).by(-1)
\r
1207 r = GroundPicture.find @gp.id
\r
1208 }.should raise_error
\r
1211 r = @panel.destroy_with_elements
\r
1215 context '削除に失敗したとき' do
\r
1217 PanelPicture.any_instance.stub(:destroy).with(any_args).and_return(false)
\r
1220 r = @panel.destroy_with_elements
\r
1223 it 'ロールバックしている' do
\r
1225 r = @panel.destroy_with_elements
\r
1226 }.should_not change(Panel, :count)
\r
1228 r = @panel.destroy_with_elements
\r
1229 }.should_not change(PanelPicture, :count)
\r
1234 describe 'id挿げ替え防止確認に於いて' do
\r
1237 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
1238 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
\r
1239 @sb = @panel.speech_balloons.create(
\r
1240 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
1242 @gc = @panel.ground_colors.create(
\r
1243 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
1245 @gp = @panel.ground_pictures.create(
\r
1246 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
\r
1248 @pc = @panel.panel_colors.create(
\r
1249 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
1253 it 'author,コマ要素を含んでいる' do
\r
1254 @panel2 = FactoryGirl.create :panel, :author_id => @author.id
\r
1255 @panel2.panel_pictures.create(
\r
1256 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height)
\r
1261 describe 'id一致チェックに於いて' do
\r
1262 #parent.idがNilのときはすべてNil。数値のときは全一致
\r
1263 context '親が既存(idが数値)のとき' do
\r
1264 it 'すべてid一致するときTrueを返す' do
\r
1265 r = Panel.validate_id [1, 1, 1, 1], 1
\r
1268 it 'idが一致する中にNilが混じってもTrueを返す' do
\r
1269 r = Panel.validate_id [1, 1, 1, 1, nil], 1
\r
1272 it 'すべて数値でも一致しないときFalseを返す' do
\r
1273 r = Panel.validate_id [1, 1, 1, 1, 2], 1
\r
1276 it '数値とNilが混ざってもIDが一致しないときFalseを返す' do
\r
1277 r = Panel.validate_id [1, 1, nil, 2], 1
\r
1281 context '親が新規(idがNil)のとき' do
\r
1282 it 'すべてNilはTrueを返す' do
\r
1283 r = Panel.validate_id [ nil,nil,nil,nil], nil
\r
1286 it 'すべてnilでなければFalseを返す' do
\r
1287 r = Panel.validate_id [nil,nil,nil,nil, 2], nil
\r
1292 describe 'idチェック単体に於いて' do
\r
1294 # @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1
\r
1296 context 'つつがなく終わるとき' do
\r
1297 it 'idを収集依頼している' do
\r
1298 Panel.should_receive(:collect_element_value).with(any_args).exactly(1)
\r
1299 Panel.stub(:collect_element_value).with(any_args).and_return([])
\r
1300 Panel.stub(:validate_id).with(any_args).and_return(true)
\r
1301 r = Panel.validate_element_id [], :panel_id, nil
\r
1303 it '収集したidを一致チェック依頼している' do
\r
1304 Panel.should_receive(:validate_id).with(any_args).exactly(1)
\r
1305 Panel.stub(:collect_element_value).with(any_args).and_return([])
\r
1306 Panel.stub(:validate_id).with(any_args).and_return(true)
\r
1307 r = Panel.validate_element_id [], :panel_id, nil
\r
1311 #依頼チェックだけでは不安なので最低限のチェックを
\r
1312 context 'コマ新規のとき' do
\r
1313 it 'コマ絵で正常通過している' do
\r
1314 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1315 @panel.panel_pictures.build(
\r
1316 FactoryGirl.attributes_for(:panel_picture, :panel_id => nil, :picture_id => @p.id, :t => nil)
\r
1318 r = Panel.validate_element_id [@panel.panel_pictures, @panel.speech_balloons], :panel_id, @panel.id
\r
1321 it 'フキダシで正常通過している' do
\r
1322 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1323 @panel.speech_balloons.build(
\r
1324 FactoryGirl.attributes_for(:speech_balloon, :panel_id => nil, :speech_balloon_template_id => @sbt.id)
\r
1326 r = Panel.validate_element_id [@panel.panel_pictures, @panel.speech_balloons], :panel_id, @panel.id
\r
1330 context 'コマ既存のとき' do
\r
1331 it 'コマ絵で正常通過している' do
\r
1332 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
1333 @panel.panel_pictures.build(
\r
1334 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => nil)
\r
1336 r = Panel.validate_element_id [@panel.panel_pictures, @panel.speech_balloons], :panel_id, @panel.id
\r
1339 it 'フキダシで正常通過している' do
\r
1340 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
1341 @panel.speech_balloons.build(
\r
1342 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id)
\r
1344 r = Panel.validate_element_id [@panel.panel_pictures, @panel.speech_balloons], :panel_id, @panel.id
\r
1348 context 'フキダシ新規のとき' do
\r
1349 it 'バルーンで正常通過している' do
\r
1350 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1351 @panel.speech_balloons.build(
\r
1352 FactoryGirl.attributes_for(:speech_balloon, :panel_id => nil, :speech_balloon_template_id => @sbt.id)
\r
1354 @panel.speech_balloons.first.balloons.build(
\r
1355 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => nil)
\r
1357 r = Panel.validate_element_id [@panel.speech_balloons.first.speeches, @panel.speech_balloons.first.balloons], :speech_balloon_id, @panel.speech_balloons.first.id
\r
1360 it 'セリフで正常通過している' do
\r
1361 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1362 @panel.speech_balloons.build(
\r
1363 FactoryGirl.attributes_for(:speech_balloon, :panel_id => nil, :speech_balloon_template_id => @sbt.id)
\r
1365 @panel.speech_balloons.first.speeches.build(
\r
1366 FactoryGirl.attributes_for(:speech, :speech_balloon_id => nil)
\r
1368 r = Panel.validate_element_id [@panel.speech_balloons.first.speeches, @panel.speech_balloons.first.balloons], :speech_balloon_id, @panel.speech_balloons.first.id
\r
1373 describe 'idチェックリスト生成に於いて' do
\r
1375 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1377 context 'つつがなく終わるとき' do
\r
1378 it 'コマ部品とフキダシ部品のトータル2を返す' do
\r
1379 @panel.panel_pictures.build(
\r
1380 FactoryGirl.attributes_for(:panel_picture, :panel_id => nil, :picture_id => @p.id, :t => nil)
\r
1382 @panel.speech_balloons.build(
\r
1383 FactoryGirl.attributes_for(:speech_balloon, :panel_id => nil, :speech_balloon_template_id => @sbt.id)
\r
1385 @panel.speech_balloons.first.balloons.build(
\r
1386 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => nil)
\r
1388 @panel.speech_balloons.first.speeches.build(
\r
1389 FactoryGirl.attributes_for(:speech, :speech_balloon_id => nil)
\r
1391 r = @panel.validate_id_list
\r
1392 r.should have(2).items
\r
1394 it 'コマ部品とフキダシ部品[複数:2]のケースでトータル3を返す' do
\r
1395 @panel.panel_pictures.build(
\r
1396 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => nil)
\r
1398 sb1 = @panel.speech_balloons.build(
\r
1399 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id)
\r
1401 sb1.balloons.build(
\r
1402 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb1.id)
\r
1404 sb1.speeches.build(
\r
1405 FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb1.id)
\r
1407 sb2 = @panel.speech_balloons.build(
\r
1408 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id)
\r
1410 sb2.balloons.build(
\r
1411 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb2.id)
\r
1413 sb2.speeches.build(
\r
1414 FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb2.id)
\r
1416 r = @panel.validate_id_list
\r
1417 r.should have(3).items
\r
1421 describe 'idチェック複合に於いて' do
\r
1423 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1425 context 'つつがなく終わるとき' do
\r
1426 it 'コマ部品とフキダシ部品の二回チェック依頼している' do
\r
1427 Panel.should_receive(:validate_element_id).with(any_args).exactly(2)
\r
1428 Panel.stub(:validate_element_id).with(any_args).and_return(true)
\r
1429 @panel.panel_pictures.build(
\r
1430 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => nil)
\r
1432 sb1 = @panel.speech_balloons.build(
\r
1433 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id)
\r
1435 sb1.balloons.build(
\r
1436 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb1.id)
\r
1438 sb1.speeches.build(
\r
1439 FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb1.id)
\r
1441 r = Panel.validate_elements_id(@panel.validate_id_list)
\r