1 # -*- encoding: utf-8 -*-
\r
2 require 'spec_helper'
\r
6 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
11 @user = FactoryGirl.create( :user_yas)
\r
12 @author = @user.author
\r
13 @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
\r
14 @other_user = FactoryGirl.create( :user_yas)
\r
15 @other_author = @other_user.author
\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
37 @panel.should be_valid
46 @panel.publish = 99999
47 @panel.should be_valid
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
208 panel = FactoryGirl.create :panel, :author_id => @author.id
\r
209 panel.own?(@author).should == true
\r
212 panel = FactoryGirl.create :panel, :author_id => @author.id
\r
213 panel.own?(@other_author).should == false
\r
216 panel = FactoryGirl.create :panel, :author_id => @author.id
\r
217 panel.own?(nil).should == false
\r
221 describe '閲覧許可に於いて' do
\r
224 it '自作のコマを見るときは許可する' do
\r
225 Panel.any_instance.stub(:own?).and_return(true)
\r
226 Panel.any_instance.stub(:publish?).and_return(true)
\r
227 panel = FactoryGirl.create :panel, :author_id => @author.id
\r
228 panel.visible?(@author).should == true
\r
230 it '自作のコマは非公開でも許可する' do
\r
231 Panel.any_instance.stub(:own?).and_return(true)
\r
232 Panel.any_instance.stub(:publish?).and_return(false)
\r
233 panel = FactoryGirl.create :panel, :author_id => @author.id
\r
234 panel.visible?(@author).should == true
\r
236 it '他人のコマでも公開なら許可する' do
\r
237 Panel.any_instance.stub(:own?).and_return(false)
\r
238 Panel.any_instance.stub(:publish?).and_return(true)
\r
239 panel = FactoryGirl.create :panel, :author_id => @author.id
\r
240 panel.visible?(@author).should == true
\r
242 it '他人のコマで非公開なら許可しない' do
\r
243 Panel.any_instance.stub(:own?).and_return(false)
\r
244 Panel.any_instance.stub(:publish?).and_return(false)
\r
245 panel = FactoryGirl.create :panel, :author_id => @author.id
\r
246 panel.visible?(@author).should == false
\r
250 describe '一覧取得に於いて' do
\r
252 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
254 context 'page補正について' do
\r
255 it '文字列から数値に変換される' do
\r
256 Panel.page('8').should eq 8
\r
258 it 'nilの場合は1になる' do
\r
259 Panel.page().should eq 1
\r
261 it '0以下の場合は1になる' do
\r
262 Panel.page('0').should eq 1
\r
265 context 'page_size補正について' do
\r
266 it '文字列から数値に変換される' do
\r
267 Panel.page_size('7').should eq 7
\r
269 it 'nilの場合はPanel.default_page_sizeになる' do
\r
270 Panel.page_size().should eq Panel.default_page_size
\r
272 it '0以下の場合はPanel.default_page_sizeになる' do
\r
273 Panel.page_size('0').should eq Panel.default_page_size
\r
275 it 'Panel.max_page_sizeを超えた場合はPanel.max_page_sizeになる' do
\r
276 Panel.page_size('1000').should eq Panel.max_page_size
\r
281 r.should eq [@panel]
\r
284 #公開コミックは(他人のコミックであっても)含んでいる
285 npl = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 100
\r
287 r.should eq [npl, @panel]
\r
289 it '非公開のコマ(自分のコマであっても)は含まない' do
\r
290 npl = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0
\r
292 r.should eq [@panel]
\r
294 context 'DBに5件あって1ページの件数を2件に変えたとして' do
\r
296 @npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100
\r
297 @npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200
\r
298 @npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300
\r
299 @npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400
\r
300 Panel.stub(:default_page_size).and_return(2)
\r
304 pl.should have(2).items
\r
306 it 'page=1なら末尾2件を返す' do
\r
309 pl.should eq [@npl5, @npl4]
\r
311 it 'page=2なら中間2件を返す' do
\r
313 pl.should eq [@npl3, @npl2]
\r
315 it 'page=3なら先頭1件を返す' do
\r
317 pl.should eq [@panel]
\r
320 context 'DBに5件あって1ページの件数を2件に変えたとして' do
322 @npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100
\r
323 @npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200
\r
324 @npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300
\r
325 @npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400
\r
326 Panel.stub(:default_page_size).and_return(2)
\r
328 it '件数0は全件(5件)を返す' do
330 r.should have(5).items
334 describe 'list関連テーブルプションに於いて' do
\r
335 it 'includeキーを含んでいる' do
\r
337 r.has_key?(:include).should be_true
\r
339 it '6つの項目を含んでいる' do
\r
340 r = Panel.list_opt[:include]
\r
341 r.should have(6).items
\r
344 r = Panel.list_opt[:include]
\r
345 r.has_key?(:panel_pictures).should be_true
\r
347 it 'コマ絵は実素材を含んでいる' do
\r
348 r = Panel.list_opt[:include]
\r
349 r[:panel_pictures].has_key?(:picture).should be_true
\r
351 it '実素材は絵師を含んでいる' do
\r
352 r = Panel.list_opt[:include]
\r
353 r[:panel_pictures][:picture].has_key?(:artist).should be_true
\r
355 it '実素材はライセンスを含んでいる' do
\r
356 r = Panel.list_opt[:include]
\r
357 r[:panel_pictures][:picture].has_key?(:license).should be_true
\r
360 r = Panel.list_opt[:include]
\r
361 r.has_key?(:speech_balloons).should be_true
\r
363 it 'フキダシはフキダシ枠を含んでいる' do
\r
364 r = Panel.list_opt[:include]
\r
365 r[:speech_balloons].has_key?(:balloons).should be_true
\r
367 it 'フキダシはセリフを含んでいる' do
\r
368 r = Panel.list_opt[:include]
\r
369 r[:speech_balloons].has_key?(:speeches).should be_true
\r
372 r = Panel.list_opt[:include]
\r
373 r.has_key?(:ground_pictures).should be_true
\r
375 it '景色画像は実素材を含んでいる' do
\r
376 r = Panel.list_opt[:include]
\r
377 r[:ground_pictures].has_key?(:picture).should be_true
\r
379 it '実素材は絵師を含んでいる' do
\r
380 r = Panel.list_opt[:include]
\r
381 r[:ground_pictures][:picture].has_key?(:artist).should be_true
\r
383 it '実素材はライセンスを含んでいる' do
\r
384 r = Panel.list_opt[:include]
\r
385 r[:ground_pictures][:picture].has_key?(:license).should be_true
\r
388 r = Panel.list_opt[:include]
\r
389 r.has_key?(:ground_colors).should be_true
\r
391 it '間接色は色を含んでいる' do
\r
392 r = Panel.list_opt[:include]
\r
393 r[:ground_colors].has_key?(:color).should be_true
\r
396 r = Panel.list_opt[:include]
\r
397 r.has_key?(:panel_colors).should be_true
\r
400 r = Panel.list_opt[:include]
\r
401 r.has_key?(:author).should be_true
\r
404 describe 'json一覧出力オプションに於いて' do
\r
407 describe '自分のコマ一覧取得に於いて' do
\r
409 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
412 pl = Panel.mylist @author
\r
413 pl.should eq [@panel]
\r
416 npl = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100
\r
417 pl = Panel.mylist @author
\r
418 pl.should eq [npl, @panel]
\r
420 it '他人のコマは公開でも含まない' do
\r
421 npl = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
\r
422 pl = Panel.mylist @author
\r
423 pl.should eq [@panel]
\r
425 it '自分のコマは非公開でも含んでいる' do
\r
426 npl = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0, :updated_at => Time.now + 100
\r
427 pl = Panel.mylist @author
\r
428 pl.should eq [npl, @panel]
\r
430 context 'DBに5件あって1ページの件数を2件に変えたとして' do
432 @npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100
\r
433 @npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200
\r
434 @npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300
\r
435 @npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400
\r
438 pl = Panel.list 1, 2
\r
439 pl.should have(2).items
\r
441 it 'page=1なら末尾2件を返す' do
\r
443 pl = Panel.mylist @author, 1, 2
\r
444 pl.should eq [@npl5, @npl4]
\r
446 it 'page=2なら中間2件を返す' do
\r
447 pl = Panel.mylist @author, 2, 2
\r
448 pl.should eq [@npl3, @npl2]
\r
450 it 'page=3なら先頭1件を返す' do
\r
451 pl = Panel.mylist @author, 3, 2
\r
452 pl.should eq [@panel]
\r
455 context 'DBに5件あって1ページの件数を0件に変えたとして' do
457 @npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100
\r
458 @npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200
\r
459 @npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300
\r
460 @npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400
\r
461 Panel.stub(:default_page_size).and_return(2)
\r
464 r = Panel.mylist @author, 5, 0
465 r.should have(5).items
470 describe '単体取得に於いて' do
\r
472 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
474 context 'つつがなく終わるとき' do
\r
475 it '単体取得オプションを利用している' do
\r
476 Panel.stub(:show_opt).with(any_args).and_return({})
\r
477 Panel.should_receive(:show_opt).with(any_args).exactly(1)
\r
478 r = Panel.show @panel.id, @author
480 it '閲覧許可を問い合わせている' do
\r
481 Panel.any_instance.stub(:visible?).with(any_args).and_return(true)
\r
482 Panel.any_instance.should_receive(:visible?).with(any_args).exactly(1)
\r
483 r = Panel.show @panel.id, @author
487 Panel.any_instance.stub(:visible?).and_return(true)
\r
488 pl = Panel.show @panel.id, @author
\r
489 pl.should eq @panel
\r
491 context '閲覧許可が出なかったとき' do
\r
492 it '403Forbidden例外を返す' do
\r
493 Panel.any_instance.stub(:visible?).and_return(false)
\r
495 Panel.show @panel.id, @author
\r
496 }.should raise_error(ActiveRecord::Forbidden)
\r
499 context '存在しないコマを開こうとしたとき' do
\r
500 it '404RecordNotFound例外を返す' do
\r
502 Panel.show 110, @author
\r
503 }.should raise_error(ActiveRecord::RecordNotFound)
\r
507 describe '編集取得に於いて' do
\r
509 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
511 context 'つつがなく終わるとき' do
\r
512 it '単体取得オプションを利用している' do
\r
513 Panel.stub(:show_opt).with(any_args).and_return({})
\r
514 Panel.should_receive(:show_opt).with(any_args).exactly(1)
\r
515 r = Panel.edit @panel.id, @author
517 it '所持判定を問い合わせている' do
\r
518 Panel.any_instance.stub(:own?).with(any_args).and_return(true)
\r
519 Panel.any_instance.should_receive(:own?).with(any_args).exactly(1)
\r
520 r = Panel.edit @panel.id, @author
524 Panel.any_instance.stub(:own?).and_return(true)
\r
525 pl = Panel.edit @panel.id, @author
\r
526 pl.should eq @panel
\r
528 context '他人のコマを開こうとしたとき' do
\r
529 it '403Forbidden例外を返す' do
\r
530 Panel.any_instance.stub(:own?).and_return(false)
\r
532 Panel.edit @panel.id, @author
\r
533 }.should raise_error(ActiveRecord::Forbidden)
\r
536 context '存在しないコマを開こうとしたとき' do
\r
537 it '404RecordNotFound例外を返す' do
\r
539 Panel.edit 110, @author
\r
540 }.should raise_error(ActiveRecord::RecordNotFound)
\r
544 describe '関連テーブルプションに於いて' do
\r
545 it 'includeキーを含んでいる' do
\r
547 r.has_key?(:include).should be_true
\r
549 it '6つの項目を含んでいる' do
\r
550 r = Panel.show_opt[:include]
\r
551 r.should have(6).items
\r
554 r = Panel.show_opt[:include]
\r
555 r.has_key?(:panel_pictures).should be_true
\r
557 it 'コマ絵は実素材を含んでいる' do
\r
558 r = Panel.show_opt[:include]
\r
559 r[:panel_pictures].has_key?(:picture).should be_true
\r
561 it '実素材は絵師を含んでいる' do
\r
562 r = Panel.show_opt[:include]
\r
563 r[:panel_pictures][:picture].has_key?(:artist).should be_true
\r
565 it '実素材はライセンスを含んでいる' do
\r
566 r = Panel.show_opt[:include]
\r
567 r[:panel_pictures][:picture].has_key?(:license).should be_true
\r
570 r = Panel.show_opt[:include]
\r
571 r.has_key?(:speech_balloons).should be_true
\r
573 it 'フキダシはフキダシ枠を含んでいる' do
\r
574 r = Panel.show_opt[:include]
\r
575 r[:speech_balloons].has_key?(:balloons).should be_true
\r
577 it 'フキダシはセリフを含んでいる' do
\r
578 r = Panel.show_opt[:include]
\r
579 r[:speech_balloons].has_key?(:speeches).should be_true
\r
582 r = Panel.show_opt[:include]
\r
583 r.has_key?(:ground_pictures).should be_true
\r
585 it '景色画像は実素材を含んでいる' do
\r
586 r = Panel.show_opt[:include]
\r
587 r[:ground_pictures].has_key?(:picture).should be_true
\r
589 it '実素材は絵師を含んでいる' do
\r
590 r = Panel.show_opt[:include]
\r
591 r[:ground_pictures][:picture].has_key?(:artist).should be_true
\r
593 it '実素材はライセンスを含んでいる' do
\r
594 r = Panel.show_opt[:include]
\r
595 r[:ground_pictures][:picture].has_key?(:license).should be_true
\r
598 r = Panel.show_opt[:include]
\r
599 r.has_key?(:ground_colors).should be_true
\r
601 it '間接色は色を含んでいる' do
\r
602 r = Panel.show_opt[:include]
\r
603 r[:ground_colors].has_key?(:color).should be_true
\r
606 r = Panel.show_opt[:include]
\r
607 r.has_key?(:panel_colors).should be_true
\r
610 r = Panel.show_opt[:include]
\r
611 r.has_key?(:author).should be_true
\r
614 describe 'json単体出力オプションに於いて' do
\r
616 describe 'コマ部品集合に於いて' do
\r
619 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
620 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
\r
621 @sb = @panel.speech_balloons.create(
\r
622 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
624 @gc = @panel.ground_colors.create(
\r
625 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
627 @gp = @panel.ground_pictures.create(
\r
628 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
\r
630 @pc = @panel.panel_colors.create(
\r
631 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
636 r = @panel.parts_element
\r
637 r.is_a?(Array).should be_true
\r
639 it 'コマ絵とフキダシを合わせている' do
\r
640 r = @panel.parts_element
\r
641 r.include?(@pp).should be_true
\r
642 r.include?(@sb).should be_true
\r
644 it '景色素材と景色カラーと景色カラーコードを含んでいない' do
\r
645 r = @panel.parts_element
\r
646 r.include?(@gc).should_not be_true
\r
647 r.include?(@gp).should_not be_true
\r
648 r.include?(@pc).should_not be_true
\r
651 describe 'コマ部品に於いて' do
\r
654 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
655 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
\r
656 @sb = @panel.speech_balloons.create(
\r
657 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
659 @gc = @panel.ground_colors.create(
\r
660 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
662 @gp = @panel.ground_pictures.create(
\r
663 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
\r
665 @pc = @panel.panel_colors.create(
\r
666 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
670 context 'つつがなく終わるとき' do
\r
671 it 'コマ部品集合を利用している' do
\r
672 Panel.any_instance.stub(:parts_element).with(any_args).and_return([])
\r
673 Panel.any_instance.should_receive(:parts_element).with(any_args).exactly(1)
\r
679 r.is_a?(Array).should be_true
\r
687 context 'さらに末尾にフキダシを追加したとき' do
\r
689 @sb2 = @panel.speech_balloons.create(
\r
690 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 2)
\r
698 r[2].should eq @sb2
\r
702 describe 'コマ地に於いて' do
\r
705 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
706 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
\r
707 @sb = @panel.speech_balloons.create(
\r
708 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
710 @gc = @panel.ground_colors.create(
\r
711 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
713 @gp = @panel.ground_pictures.create(
\r
714 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
\r
716 @pc = @panel.panel_colors.create(
\r
717 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
723 r.is_a?(Array).should be_true
\r
725 it '景色素材と景色カラーと景色カラーコードを合わせている' do
\r
727 r.include?(@gc).should be_true
\r
728 r.include?(@gp).should be_true
\r
729 r.include?(@pc).should be_true
\r
731 it 'コマ絵とフキダシを含んでいない' do
\r
733 r.include?(@pp).should_not be_true
\r
734 r.include?(@sb).should_not be_true
\r
737 describe 'コマ要素に於いて' do
\r
740 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
741 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
\r
742 @sb = @panel.speech_balloons.create(
\r
743 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
745 @gc = @panel.ground_colors.create(
\r
746 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
748 @gp = @panel.ground_pictures.create(
\r
749 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
\r
751 @pc = @panel.panel_colors.create(
\r
752 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
756 context 'つつがなく終わるとき' do
\r
757 it 'コマ部品を利用している' do
\r
758 Panel.any_instance.stub(:parts).with(any_args).and_return([])
\r
759 Panel.any_instance.should_receive(:parts).with(any_args).exactly(1)
\r
760 r = @panel.panel_elements
\r
763 Panel.any_instance.stub(:grounds).with(any_args).and_return([])
\r
764 Panel.any_instance.should_receive(:grounds).with(any_args).exactly(1)
\r
765 r = @panel.panel_elements
\r
769 r = @panel.panel_elements
\r
770 r.is_a?(Array).should be_true
\r
772 it 'コマ絵とフキダシを合わせている' do
\r
773 r = @panel.panel_elements
\r
774 r.include?(@pp).should be_true
\r
775 r.include?(@sb).should be_true
\r
777 it '景色素材と景色カラーと景色カラーコードを合わせている' do
\r
778 r = @panel.panel_elements
\r
779 r.include?(@gc).should be_true
\r
780 r.include?(@gp).should be_true
\r
781 r.include?(@pc).should be_true
\r
783 it 'tでソートしている[t順にソートできる部品の方が優先順位は高い。]' do
\r
784 r = @panel.panel_elements
\r
789 describe 'コマ要素のjson出力に於いて' do
\r
792 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
793 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
\r
794 @sb = @panel.speech_balloons.create(
\r
795 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
797 @gc = @panel.ground_colors.create(
\r
798 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
800 @gp = @panel.ground_pictures.create(
\r
801 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
\r
803 @pc = @panel.panel_colors.create(
\r
804 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
808 context 'つつがなく終わるとき' do
\r
810 Panel.stub(:elm_json_opt).with(@pp).and_return({})
\r
811 Panel.stub(:elm_json_opt).with(@sb).and_return({})
\r
812 Panel.stub(:elm_json_opt).with(@gp).and_return({})
\r
813 Panel.stub(:elm_json_opt).with(@gc).and_return({})
\r
814 Panel.stub(:elm_json_opt).with(@pc).and_return({})
\r
816 it 'コマ要素のjson出力オプションにコマ絵json出力オプションを依頼している' do
\r
817 Panel.should_receive(:elm_json_opt).with(@pp).exactly(1)
\r
818 r = @panel.elements
\r
820 it 'コマ要素のjson出力オプションにフキダシjson出力オプションを依頼している' do
\r
821 Panel.should_receive(:elm_json_opt).with(@sb).exactly(1)
\r
822 r = @panel.elements
\r
824 it 'コマ要素のjson出力オプションに景色素材json出力オプションを依頼している' do
\r
825 Panel.should_receive(:elm_json_opt).with(@gp).exactly(1)
\r
826 r = @panel.elements
\r
828 it 'コマ要素のjson出力オプションに景色カラーjson出力オプションを依頼している' do
\r
829 Panel.should_receive(:elm_json_opt).with(@gc).exactly(1)
\r
830 r = @panel.elements
\r
832 it 'コマ要素のjson出力オプションに景色カラーコードjson出力オプションを依頼している' do
\r
833 Panel.should_receive(:elm_json_opt).with(@pc).exactly(1)
\r
834 r = @panel.elements
\r
838 r = @panel.elements
\r
839 r.is_a?(Array).should be_true
\r
842 describe 'コマのjson出力に於いて' do
\r
845 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
846 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
\r
847 @sb = @panel.speech_balloons.create(
\r
848 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
850 @gc = @panel.ground_colors.create(
\r
851 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
853 @gp = @panel.ground_pictures.create(
\r
854 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
\r
856 @pc = @panel.panel_colors.create(
\r
857 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
861 context 'つつがなく終わるとき' do
\r
863 Panel.any_instance.stub(:elements).with(any_args).and_return({})
\r
865 it 'コマ要素のjson出力を依頼している' do
\r
866 Panel.any_instance.should_receive(:elements).with(any_args).exactly(1)
\r
867 r = @panel.panel_elements_as_json
\r
870 it 'json textを返している' do
\r
871 r = JSON.parse @panel.panel_elements_as_json
\r
872 r.is_a?(Hash).should be_true
\r
874 it 'author,コマ要素を含んでいる' do
\r
875 r = JSON.parse @panel.panel_elements_as_json
\r
876 r.has_key?('author').should be_true
\r
877 r.has_key?('elements').should be_true
\r
879 sb = r['elements'].first
\r
880 sb.has_key?('classname').should be_true
\r
881 sb.has_key?('balloons').should be_true
\r
882 sb.has_key?('speeches').should be_true
\r
886 describe 'コマリストのjson出力に於いて' do
\r
888 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
889 Panel.any_instance.stub(:panel_elements_as_json).with(any_args).and_return('{"p": 5}')
\r
891 context 'つつがなく終わるとき' do
\r
892 it 'コマのjson出力を依頼している' do
\r
893 Panel.any_instance.should_receive(:panel_elements_as_json).with(any_args).exactly(1)
\r
894 r = Panel.list_as_json_text [@panel]
\r
897 it 'json textを返している' do
\r
898 r = Panel.list_as_json_text [@panel]
\r
900 j.is_a?(Array).should be_true
\r
903 r = Panel.list_as_json_text [@panel]
\r
905 j.first.has_key?('p').should be_true
\r
908 describe '検証値収集に於いて' do
\r
909 context 'つつがなく終わるとき' do
\r
910 it '第一パラメータで指定された配列中から第二引数のカラム値を収集している' do
\r
911 elements = [[{:panel_id => 1, :a => 'a'}, {:panel_id => 2, :a => 'a'}],
\r
912 [{:panel_id => 3, :a => 'a'}, {:panel_id => 4, :a => 'a'}]]
\r
913 r = Panel.collect_element_value elements, :panel_id
\r
914 r.should eq [1, 2, 3, 4]
\r
916 it '第一パラメータで指定された配列中から第二引数のカラム値を収集している' do
\r
917 elements = [[{:t => 1, :a => 'a'}, {:t => 2, :a => 'a'}],
\r
918 [{:t => 3, :a => 'a'}, {:t => 0, :a => 'a'}]]
\r
919 r = Panel.collect_element_value elements, :t
\r
920 r.should eq [1, 2, 3, 0]
\r
924 describe 'シリアライズチェックに於いて' do
\r
925 context 'つつがなく終わるとき' do
\r
926 it '0からシリアライズされているならTrueを返す' do
\r
927 r = Panel.validate_t [0, 1, 2]
\r
930 it '見た目はシリアライズされてなくてもソート結果が無事ならtrueを返す' do
\r
931 r = Panel.validate_t [0, 2, 1]
\r
934 it '見た目はシリアライズされてなくてもソート結果が無事ならtrueを返す' do
\r
935 r = Panel.validate_t [ 2, 1, 4, 3, 0]
\r
940 it '0から始まらないならFalseを返す' do
\r
941 r = Panel.validate_t [1, 2, 3]
\r
944 it '連続していないならFalseを返す' do
\r
945 r = Panel.validate_t [0, 1, 2, 4]
\r
948 it '連続していないならFalseを返す' do
\r
949 r = Panel.validate_t [0, 1, 2, 4, 5]
\r
954 describe 'tチェック単体に於いて' do
\r
957 context 'つつがなく終わるとき' do
\r
958 it '検証値収集を依頼している' do
\r
959 Panel.should_receive(:collect_element_value).with(any_args).exactly(1)
\r
960 Panel.stub(:collect_element_value).with(any_args).and_return([])
\r
961 Panel.stub(:validate_t).with(any_args).and_return(true)
\r
962 r = Panel.validate_element_t [], :t
\r
964 it 'シリアライズチェック依頼している' do
\r
965 Panel.stub(:collect_element_value).with(any_args).and_return([])
\r
966 Panel.should_receive(:validate_t).with(any_args).exactly(1)
\r
967 Panel.stub(:validate_t).with(any_args).and_return(true)
\r
968 r = Panel.validate_element_t [], :t
\r
972 describe '従属データの検証に於いて' do
\r
973 context 'つつがなく終わるとき' do
\r
975 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
976 @panel.panel_pictures.build(
\r
977 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 0)
\r
979 @panel.panel_pictures.build(
\r
980 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 1)
\r
982 sb1 = @panel.speech_balloons.build(
\r
983 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 2)
\r
985 sb1.balloons.build(
\r
986 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb1.id)
\r
988 sb1.speeches.build(
\r
989 FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb1.id)
\r
991 sb2 = @panel.speech_balloons.build(
\r
992 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 3)
\r
994 sb2.balloons.build(
\r
995 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb2.id)
\r
997 sb2.speeches.build(
\r
998 FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb2.id)
\r
1000 r = @panel.validate_child
\r
1004 context 'シリアライズされていないとき' do
\r
1005 it 'falseを返している' do
\r
1006 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1007 @panel.panel_pictures.build(
\r
1008 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 0)
\r
1010 @panel.panel_pictures.build(
\r
1011 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 1)
\r
1013 sb1 = @panel.speech_balloons.build(
\r
1014 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 2)
\r
1016 sb1.balloons.build(
\r
1017 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb1.id)
\r
1019 sb1.speeches.build(
\r
1020 FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb1.id)
\r
1022 sb2 = @panel.speech_balloons.build(
\r
1023 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 4)
\r
1025 sb2.balloons.build(
\r
1026 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb2.id)
\r
1028 sb2.speeches.build(
\r
1029 FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb2.id)
\r
1031 r = @panel.validate_child
\r
1036 describe '保存に於いて' do
\r
1038 @attr = FactoryGirl.attributes_for :panel
\r
1040 @panel.supply_default
1042 context 'つつがなく終わるとき' do
\r
1044 Panel.any_instance.stub(:validate_child).with(any_args).and_return(true)
\r
1045 Panel.any_instance.stub(:save).with(any_args).and_return(true)
\r
1047 it 'コマモデルに上書き補充を依頼している' do
\r
1048 Panel.any_instance.should_receive(:overwrite).exactly(1)
\r
1049 r = @panel.store @attr, @author
\r
1051 it '従属データの検証を依頼している' do
\r
1052 Panel.any_instance.should_receive(:validate_child).with(any_args).exactly(1)
\r
1053 r = @panel.store @attr, @author
\r
1056 Panel.any_instance.should_receive(:save).with(any_args).exactly(1)
\r
1057 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1058 r = @panel.store @attr, @author
\r
1061 context 'つつがなく終わるとき' do
\r
1063 Panel.any_instance.stub(:validate_child).with(any_args).and_return(true)
\r
1066 r = @panel.store @attr, @author
\r
1070 Panel.any_instance.stub(:validate_child).with(any_args).and_return(true)
\r
1072 r = @panel.store @attr, @author
\r
1073 }.should change(Panel, :count)
\r
1076 context '従属データの検証に失敗したとき' do
\r
1078 Panel.any_instance.stub(:validate_child).with(any_args).and_return(false)
\r
1080 it 'エラーメッセージがセットされている' do
\r
1081 r = @panel.store @attr, @author
\r
1082 @panel.errors.should_not be_empty
\r
1085 context 'カラム値がFalseしたとき' do
\r
1087 Panel.any_instance.stub(:validate_child).with(any_args).and_return(true)
\r
1089 it 'エラーメッセージがセットされている' do
\r
1090 r = @panel.store false, @author
\r
1091 @panel.errors.should_not be_empty
\r
1096 describe 'id挿げ替え防止確認に於いて' do
\r
1099 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
1100 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
\r
1101 @sb = @panel.speech_balloons.create(
\r
1102 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
\r
1104 @gc = @panel.ground_colors.create(
\r
1105 FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
\r
1107 @gp = @panel.ground_pictures.create(
\r
1108 FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
\r
1110 @pc = @panel.panel_colors.create(
\r
1111 FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
\r
1115 it 'author,コマ要素を含んでいる' do
\r
1116 @panel2 = FactoryGirl.create :panel, :author_id => @author.id
\r
1117 @panel2.panel_pictures.create(
\r
1118 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height)
\r
1122 p @panel2.panel_pictures
\r
1125 describe 'id一致チェックに於いて' do
\r
1126 #parent.idがNilのときはすべてNil。数値のときは全一致
\r
1127 context '親が既存(idが数値)のとき' do
\r
1128 it 'すべてid一致するときTrueを返す' do
\r
1129 r = Panel.validate_id [1, 1, 1, 1], 1
\r
1132 it 'idが一致する中にNilが混じってもTrueを返す' do
\r
1133 r = Panel.validate_id [1, 1, 1, 1, nil], 1
\r
1136 it 'すべて数値でも一致しないときFalseを返す' do
\r
1137 r = Panel.validate_id [1, 1, 1, 1, 2], 1
\r
1140 it '数値とNilが混ざってもIDが一致しないときFalseを返す' do
\r
1141 r = Panel.validate_id [1, 1, nil, 2], 1
\r
1145 context '親が新規(idがNil)のとき' do
\r
1146 it 'すべてNilはTrueを返す' do
\r
1147 r = Panel.validate_id [ nil,nil,nil,nil], nil
\r
1150 it 'すべてnilでなければFalseを返す' do
\r
1151 r = Panel.validate_id [nil,nil,nil,nil, 2], nil
\r
1156 describe 'idチェック単体に於いて' do
\r
1158 # @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1
\r
1160 context 'つつがなく終わるとき' do
\r
1161 it 'idを収集依頼している' do
\r
1162 Panel.should_receive(:collect_element_value).with(any_args).exactly(1)
\r
1163 Panel.stub(:collect_element_value).with(any_args).and_return([])
\r
1164 Panel.stub(:validate_id).with(any_args).and_return(true)
\r
1165 r = Panel.validate_element_id [], :panel_id, nil
\r
1167 it '収集したidを一致チェック依頼している' do
\r
1168 Panel.should_receive(:validate_id).with(any_args).exactly(1)
\r
1169 Panel.stub(:collect_element_value).with(any_args).and_return([])
\r
1170 Panel.stub(:validate_id).with(any_args).and_return(true)
\r
1171 r = Panel.validate_element_id [], :panel_id, nil
\r
1175 #依頼チェックだけでは不安なので最低限のチェックを
\r
1176 context 'コマ新規のとき' do
\r
1177 it 'コマ絵で正常通過している' do
\r
1178 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1179 @panel.panel_pictures.build(
\r
1180 FactoryGirl.attributes_for(:panel_picture, :panel_id => nil, :picture_id => @p.id, :t => nil)
\r
1182 r = Panel.validate_element_id [@panel.panel_pictures, @panel.speech_balloons], :panel_id, @panel.id
\r
1185 it 'フキダシで正常通過している' do
\r
1186 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1187 @panel.speech_balloons.build(
\r
1188 FactoryGirl.attributes_for(:speech_balloon, :panel_id => nil, :speech_balloon_template_id => @sbt.id)
\r
1190 r = Panel.validate_element_id [@panel.panel_pictures, @panel.speech_balloons], :panel_id, @panel.id
\r
1194 context 'コマ既存のとき' do
\r
1195 it 'コマ絵で正常通過している' do
\r
1196 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
1197 @panel.panel_pictures.build(
\r
1198 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => nil)
\r
1200 r = Panel.validate_element_id [@panel.panel_pictures, @panel.speech_balloons], :panel_id, @panel.id
\r
1203 it 'フキダシで正常通過している' do
\r
1204 @panel = FactoryGirl.create :panel, :author_id => @author.id
\r
1205 @panel.speech_balloons.build(
\r
1206 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id)
\r
1208 r = Panel.validate_element_id [@panel.panel_pictures, @panel.speech_balloons], :panel_id, @panel.id
\r
1212 context 'フキダシ新規のとき' do
\r
1213 it 'バルーンで正常通過している' do
\r
1214 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1215 @panel.speech_balloons.build(
\r
1216 FactoryGirl.attributes_for(:speech_balloon, :panel_id => nil, :speech_balloon_template_id => @sbt.id)
\r
1218 @panel.speech_balloons.first.balloons.build(
\r
1219 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => nil)
\r
1221 r = Panel.validate_element_id [@panel.speech_balloons.first.speeches, @panel.speech_balloons.first.balloons], :speech_balloon_id, @panel.speech_balloons.first.id
\r
1224 it 'セリフで正常通過している' do
\r
1225 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1226 @panel.speech_balloons.build(
\r
1227 FactoryGirl.attributes_for(:speech_balloon, :panel_id => nil, :speech_balloon_template_id => @sbt.id)
\r
1229 @panel.speech_balloons.first.speeches.build(
\r
1230 FactoryGirl.attributes_for(:speech, :speech_balloon_id => nil)
\r
1232 r = Panel.validate_element_id [@panel.speech_balloons.first.speeches, @panel.speech_balloons.first.balloons], :speech_balloon_id, @panel.speech_balloons.first.id
\r
1237 describe 'idチェックリスト生成に於いて' do
\r
1239 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1241 context 'つつがなく終わるとき' do
\r
1242 it 'コマ部品とフキダシ部品のトータル2を返す' do
\r
1243 @panel.panel_pictures.build(
\r
1244 FactoryGirl.attributes_for(:panel_picture, :panel_id => nil, :picture_id => @p.id, :t => nil)
\r
1246 @panel.speech_balloons.build(
\r
1247 FactoryGirl.attributes_for(:speech_balloon, :panel_id => nil, :speech_balloon_template_id => @sbt.id)
\r
1249 @panel.speech_balloons.first.balloons.build(
\r
1250 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => nil)
\r
1252 @panel.speech_balloons.first.speeches.build(
\r
1253 FactoryGirl.attributes_for(:speech, :speech_balloon_id => nil)
\r
1255 r = @panel.validate_id_list
\r
1256 r.should have(2).items
\r
1258 it 'コマ部品とフキダシ部品[複数:2]のケースでトータル3を返す' do
\r
1259 @panel.panel_pictures.build(
\r
1260 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => nil)
\r
1262 sb1 = @panel.speech_balloons.build(
\r
1263 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id)
\r
1265 sb1.balloons.build(
\r
1266 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb1.id)
\r
1268 sb1.speeches.build(
\r
1269 FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb1.id)
\r
1271 sb2 = @panel.speech_balloons.build(
\r
1272 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id)
\r
1274 sb2.balloons.build(
\r
1275 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb2.id)
\r
1277 sb2.speeches.build(
\r
1278 FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb2.id)
\r
1280 r = @panel.validate_id_list
\r
1281 r.should have(3).items
\r
1285 describe 'idチェック複合に於いて' do
\r
1287 @panel = FactoryGirl.build :panel, :author_id => @author.id
\r
1289 context 'つつがなく終わるとき' do
\r
1290 it 'コマ部品とフキダシ部品の二回チェック依頼している' do
\r
1291 Panel.should_receive(:validate_element_id).with(any_args).exactly(2)
\r
1292 Panel.stub(:validate_element_id).with(any_args).and_return(true)
\r
1293 @panel.panel_pictures.build(
\r
1294 FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => nil)
\r
1296 sb1 = @panel.speech_balloons.build(
\r
1297 FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id)
\r
1299 sb1.balloons.build(
\r
1300 FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb1.id)
\r
1302 sb1.speeches.build(
\r
1303 FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb1.id)
\r
1305 r = Panel.validate_elements_id(@panel.validate_id_list)
\r