1 # -*- encoding: utf-8 -*-
7 SpeechBalloonTemplate.delete_all
8 @admin = FactoryGirl.create :admin
9 @demand_user = FactoryGirl.create :demand_user
10 @sp = FactoryGirl.create :system_picture
11 @lg = FactoryGirl.create :license_group
12 @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
13 @user = FactoryGirl.create( :user_yas)
14 @author = FactoryGirl.create :author, :user_id => @user.id
15 @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
16 @other_user = FactoryGirl.create( :user_yas)
17 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
18 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
23 @scroll = FactoryGirl.build :scroll, :author_id => @author.id
26 context 'オーソドックスなデータのとき' do
30 @scroll.should be_valid
33 @scroll.title = 'a'*100
35 @scroll.should be_valid
39 context 'titleを検証するとき' do
42 @scroll.should_not be_valid
45 @scroll.title = 'a'*101
46 @scroll.should_not be_valid
49 context 'visibleを検証するとき' do
52 @scroll.should_not be_valid
56 @scroll.should_not be_valid
60 @scroll.should_not be_valid
64 context 'author_idを検証するとき' do
66 @scroll.author_id = nil
67 @scroll.should_not be_valid
70 @scroll.author_id = 'a'
71 @scroll.should_not be_valid
73 it '存在する作家でなければ失敗する' do
75 @scroll.should_not be_valid
80 describe '文字コード検証に於いて' do
82 @scroll = FactoryGirl.build :scroll, :author_id => @author.id
85 context 'titleを検証するとき' do
86 it 'Shift JISなら失敗する' do
87 @scroll.title = "\x83G\x83r\x83]\x83D"
90 }.should raise_error(Pettanr::BadRequest)
94 context 'descriptionを検証するとき' do
95 it 'Shift JISなら失敗する' do
96 @scroll.description = "\x83G\x83r\x83]\x83D"
99 }.should raise_error(Pettanr::BadRequest)
104 describe 'デフォルト値補充に於いて' do
105 it 'visibleが0になっている' do
106 @scroll = FactoryGirl.build :scroll, :visible => nil
107 @scroll.supply_default
108 @scroll.visible.should eq 0
112 describe '上書き補充に於いて' do
114 @scroll = FactoryGirl.build :scroll, :author_id => nil
115 @scroll.overwrite @author
116 @scroll.author_id.should eq @author.id
120 describe 'ロールリストからの作家取得に於いて' do
121 context 'ロールがユーザのとき' do
122 it 'ユーザから作家を取得して、それを返す' do
123 r = Scroll.get_author_from_roles([@user])
127 context 'ロールが作家のとき' do
129 r = Scroll.get_author_from_roles([@author])
133 context 'ロールが絵師のとき' do
134 it '絵師から作家を取得できれば、それをを返す' do
135 r = Scroll.get_author_from_roles([@artist])
138 it '絵師から作家を取得できないときnilを返す' do
139 @artist.author_id = nil
141 r = Scroll.get_author_from_roles([@artist])
145 context 'ロールが管理者のとき' do
147 r = Scroll.get_author_from_roles([@admin])
153 describe 'ロールリストからの絵師取得に於いて' do
154 context 'ロールがユーザのとき' do
155 it 'ユーザから作家を取得して、そこから絵師を取得できれば、それを返す' do
156 r = Scroll.get_artist_from_roles([@user])
159 it '作家から絵師を取得できないときnilを返す' do
160 @artist.author_id = nil
162 r = Scroll.get_artist_from_roles([@user])
166 context 'ロールが作家のとき' do
167 it 'そこから絵師を取得できれば、それを返す' do
168 r = Scroll.get_artist_from_roles([@author])
171 it '作家から絵師を取得できないときnilを返す' do
172 @artist.author_id = nil
174 r = Scroll.get_artist_from_roles([@author])
178 context 'ロールが絵師のとき' do
180 r = Scroll.get_artist_from_roles([@artist])
184 context 'ロールが管理者のとき' do
186 r = Scroll.get_artist_from_roles([@admin])
192 describe '所持判定に於いて' do
194 @scroll = FactoryGirl.build :scroll, :author_id => @author.id
196 context '事前チェックする' do
197 it '自身にロールリストからの作家取得を依頼している' do
198 Scroll.should_receive(:get_author_from_roles).with(any_args).exactly(1)
199 r = @scroll.own?([@author])
202 context 'ロール内作家が取得できるとき' do
205 it 'ロール内作家のidが自身の作家idと一致するなら許可する' do
206 Scroll.stub(:get_author_from_roles).with(any_args).and_return(@author)
207 r = @scroll.own?([@author])
210 it 'ロール内作家のidが自身の作家idと一致しないならno' do
211 Scroll.stub(:get_author_from_roles).with(any_args).and_return(@other_author)
212 @scroll.own?(@other_author).should be_false
215 context 'ロール内作家が取得できないとき' do
217 Scroll.stub(:get_author_from_roles).with(any_args).and_return(nil)
220 r = @scroll.own?([@author])
226 describe '読者用ロールチェックに於いて' do
228 @scroll = FactoryGirl.build :scroll, :author_id => @author.id
230 context 'ロールリストに作家が含まれるとき' do
231 it 'ロールリストがリストではないとき、リストにする trueを返す' do
232 r = @scroll.reader_role_check(@author)
236 r = @scroll.reader_role_check([@author])
240 context 'ロールリストに絵師が含まれるとき' do
242 r = @scroll.reader_role_check([@artist])
246 context 'ロールリストにユーザが含まれるとき' do
248 r = @scroll.reader_role_check([@user])
252 context 'ロールリストに管理者が含まれるとき' do
254 r = @scroll.reader_role_check([@admin])
258 context 'ロールリストにユーザ、管理者、作家、絵師が含まれないとき' do
260 r = @scroll.reader_role_check([nil])
266 describe '素材読者用ロールチェックに於いて' do
268 @scroll = FactoryGirl.build :scroll, :author_id => @author.id
270 context 'ロールリストに作家が含まれるとき' do
271 it 'ロールリストがリストではないとき、リストにする trueを返す' do
272 r = @scroll.resource_reader_role_check(@author)
276 r = @scroll.resource_reader_role_check([@author])
280 context 'ロールリストに絵師が含まれるとき' do
282 r = @scroll.resource_reader_role_check([@artist])
286 context 'ロールリストにユーザが含まれるとき' do
288 r = @scroll.resource_reader_role_check([@user])
292 context 'ロールリストに管理者が含まれるとき' do
294 r = @scroll.resource_reader_role_check([@admin])
298 context 'ロールリストに借手が含まれるとき' do
300 r = @scroll.resource_reader_role_check([@demand_user])
304 context 'ロールリストにユーザ、管理者、作家、絵師、借手が含まれないとき' do
306 r = @scroll.resource_reader_role_check([nil])
312 describe '閲覧許可に於いて' do
314 @scroll = FactoryGirl.build :scroll, :author_id => @author.id
316 context 'オープンモードのとき' do
318 MagicNumber['run_mode'] = 0
320 it '自身にゲスト用ロールチェックを問い合わせしている' do
321 Scroll.any_instance.stub(:guest_role_check).and_return(true)
322 Scroll.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)
323 r = @scroll.visible?([@author])
325 it 'ゲスト用ロールチェックが失敗したとき、falseを返す' do
326 Scroll.any_instance.stub(:guest_role_check).and_return(false)
327 r = @scroll.visible?([@author])
331 context 'クローズドモードのとき' do
333 MagicNumber['run_mode'] = 1
335 it '自身に読者用ロールチェックを問い合わせしている' do
336 Scroll.any_instance.stub(:reader_role_check).and_return(true)
337 Scroll.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1)
338 r = @scroll.visible?([@author])
340 it '読者用ロールチェックが失敗したとき、falseを返す' do
341 Scroll.any_instance.stub(:reader_role_check).and_return(false)
342 r = @scroll.visible?([@author])
346 context '事前チェックする' do
348 MagicNumber['run_mode'] = 1
349 Scroll.any_instance.stub(:reader_role_check).and_return(true)
350 Scroll.any_instance.stub(:own?).and_return(true)
352 it '自身に所持判定を問い合わせしている' do
353 Scroll.any_instance.should_receive(:own?).with(any_args).exactly(1)
354 r = @scroll.visible?([@author])
357 context 'つつがなく終わるとき' do
359 MagicNumber['run_mode'] = 1
360 Scroll.any_instance.stub(:reader_role_check).and_return(true)
362 it '自分のスクロールなら許可する' do
363 Scroll.any_instance.stub(:own?).and_return(true)
364 Scroll.any_instance.stub(:visible).and_return(0)
365 r = @scroll.visible?([@author])
368 it '他人の非公開スクロールなら許可しない' do
369 Scroll.any_instance.stub(:own?).and_return(false)
370 Scroll.any_instance.stub(:visible).and_return(0)
371 r = @scroll.visible?([@author])
374 it '他人のスクロールでも公開なら許可する' do
375 Scroll.any_instance.stub(:own?).and_return(false)
376 Scroll.any_instance.stub(:visible).and_return(1)
377 r = @scroll.visible?([@author])
383 describe '一覧取得に於いて' do
385 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
387 context 'page補正について' do
388 it '文字列から数値に変換される' do
389 Scroll.page('8').should eq 8
392 Scroll.page().should eq 1
395 Scroll.page('0').should eq 1
398 context 'page_size補正について' do
399 it '文字列から数値に変換される' do
400 Scroll.page_size('7').should eq 7
402 it 'nilの場合はScroll.default_page_sizeになる' do
403 Scroll.page_size().should eq Scroll.default_page_size
405 it '0以下の場合はScroll.default_page_sizeになる' do
406 Scroll.page_size('0').should eq Scroll.default_page_size
408 it 'Scroll.max_page_sizeを超えた場合はScroll.max_page_sizeになる' do
409 Scroll.page_size('1000').should eq Scroll.max_page_size
412 context 'つつがなく終わるとき' do
413 it '一覧取得オプションを利用している' do
414 Scroll.stub(:list_opt).with(any_args).and_return({})
415 Scroll.should_receive(:list_opt).with(any_args).exactly(1)
421 c.should eq [@scroll]
423 it '非公開スクロールは(自分のスクロールであっても)含んでいない' do
424 FactoryGirl.create :scroll, :author_id => @author.id, :visible => 0
426 c.should eq [@scroll]
429 #公開スクロールは(他人のスクロールであっても)含んでいる
430 v = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 100
432 c.should eq [v, @scroll]
434 context 'DBに5件あって1ページの件数を2件に変えたとして' do
436 @scroll2 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 100
437 @scroll3 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 200
438 @scroll4 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 300
439 @scroll5 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 400
440 Scroll.stub(:default_page_size).and_return(2)
444 c.should have(2).items
446 it 'page=1なら末尾2件を返す' do
449 c.should eq [@scroll5, @scroll4]
451 it 'page=2なら中間2件を返す' do
453 c.should eq [@scroll3, @scroll2]
455 it 'page=3なら先頭1件を返す' do
457 c.should eq [@scroll]
462 describe '自分のスクロール一覧取得に於いて' do
464 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
466 context 'つつがなく終わるとき' do
467 it '一覧取得オプションを利用している' do
468 Scroll.stub(:list_opt).with(any_args).and_return({})
469 Scroll.should_receive(:list_opt).with(any_args).exactly(1)
470 r = Scroll.mylist @author
474 c = Scroll.mylist @author
475 c.should eq [@scroll]
478 nc = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 100
479 cl = Scroll.mylist @author
480 cl.should eq [nc, @scroll]
482 it '他人のスクロールは公開でも含まない' do
483 nc = FactoryGirl.create :scroll, :author_id => @other_author.id, :visible => 1
484 cl = Scroll.mylist @author
485 cl.should eq [@scroll]
487 it '自分のスクロールは非公開でも含んでいる' do
488 nc = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 0, :updated_at => Time.now + 100
489 cl = Scroll.mylist @author
490 cl.should eq [nc, @scroll]
492 context 'DBに5件あって1ページの件数を2件に変えたとして' do
494 @scroll2 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 100
495 @scroll3 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 200
496 @scroll4 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 300
497 @scroll5 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 400
500 c = Scroll.mylist @author, 1, 2
501 c.should have(2).items
503 it 'page=1なら末尾2件を返す' do
505 c = Scroll.mylist(@author, 1, 2)
506 c.should eq [@scroll5, @scroll4]
508 it 'page=2なら中間2件を返す' do
509 c = Scroll.mylist(@author, 2, 2)
510 c.should eq [@scroll3, @scroll2]
512 it 'page=3なら先頭1件を返す' do
513 c = Scroll.mylist(@author, 3, 2)
514 c.should eq [@scroll]
519 describe '他作家のスクロール一覧取得に於いて' do
521 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
522 @other_scroll = FactoryGirl.create :scroll, :author_id => @other_author.id, :visible => 1
524 context 'つつがなく終わるとき' do
525 it '一覧取得オプションを利用している' do
526 Scroll.stub(:list_opt).with(any_args).and_return({})
527 Scroll.should_receive(:list_opt).with(any_args).exactly(1)
528 r = Scroll.himlist @other_author
531 it '指定した作家のリストを返す' do
532 r = Scroll.himlist @other_author
533 r.should eq [@other_scroll]
536 nc = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 100
537 r = Scroll.himlist @other_author
538 r.should eq [nc, @other_scroll]
541 hidden = FactoryGirl.create :scroll, :author_id => @other_author.id, :visible => 0
542 r = Scroll.himlist @other_author
543 r.should eq [@other_scroll]
545 context 'DBに5件あって1ページの件数を2件に変えたとして' do
547 @other_scroll2 = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 100
548 @other_scroll3 = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 200
549 @other_scroll4 = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 300
550 @other_scroll5 = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 400
553 c = Scroll.himlist @other_author, 1, 2
554 c.should have(2).items
556 it 'page=1なら末尾2件を返す' do
558 c = Scroll.himlist(@other_author, 1, 2)
559 c.should eq [@other_scroll5, @other_scroll4]
561 it 'page=2なら中間2件を返す' do
562 c = Scroll.himlist(@other_author, 2, 2)
563 c.should eq [@other_scroll3, @other_scroll2]
565 it 'page=3なら先頭1件を返す' do
566 c = Scroll.himlist(@other_author, 3, 2)
567 c.should eq [@other_scroll]
572 describe 'スクロール一覧ページ制御に於いて' do
574 Scroll.stub(:count).with(any_args).and_return(100)
577 r = Scroll.list_paginate
578 r.is_a?(Kaminari::PaginatableArray).should be_true
580 it 'スクロール一覧の取得条件を利用している' do
581 Scroll.stub(:list_where).with(any_args).and_return('')
582 Scroll.should_receive(:list_where).with(any_args).exactly(1)
583 r = Scroll.list_paginate
585 it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
586 r = Scroll.list_paginate 3, 10
587 r.limit_value.should eq 10
588 r.offset_value.should eq 20
592 describe '自分のスクロール一覧ページ制御に於いて' do
594 Scroll.stub(:count).with(any_args).and_return(100)
597 r = Scroll.mylist_paginate @author
598 r.is_a?(Kaminari::PaginatableArray).should be_true
600 it '自分のスクロール一覧の取得条件を利用している' do
601 Scroll.stub(:mylist_where).with(any_args).and_return('')
602 Scroll.should_receive(:mylist_where).with(any_args).exactly(1)
603 r = Scroll.mylist_paginate @author
605 it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
606 r = Scroll.mylist_paginate @author, 3, 10
607 r.limit_value.should eq 10
608 r.offset_value.should eq 20
612 describe '他作家のスクロール一覧ページ制御に於いて' do
614 Scroll.stub(:count).with(any_args).and_return(100)
617 r = Scroll.himlist_paginate @other_author
618 r.is_a?(Kaminari::PaginatableArray).should be_true
620 it '他作家のスクロール一覧の取得条件を利用している' do
621 Scroll.stub(:himlist_where).with(any_args).and_return('')
622 Scroll.should_receive(:himlist_where).with(any_args).exactly(1)
623 r = Scroll.himlist_paginate @other_author
625 it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
626 r = Scroll.himlist_paginate @other_author, 3, 10
627 r.limit_value.should eq 10
628 r.offset_value.should eq 20
632 describe '一覧取得オプションに於いて' do
635 r.should have(2).items
639 r.has_key?(:scroll_panels).should be_true
641 it 'スクコマはコマを含んでいる' do
643 r[:scroll_panels].has_key?(:panel).should be_true
647 r.has_key?(:author).should be_true
650 describe 'json一覧出力オプションに於いて' do
652 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
653 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
654 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
655 @sbt = FactoryGirl.create :speech_balloon_template
656 @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1
657 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
658 @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id
661 r = Scroll.list.to_json Scroll.list_json_opt
664 i.has_key?('scroll_panels').should be_true
666 it 'スクコマはコマを含んでいる' do
667 r = Scroll.list.to_json Scroll.list_json_opt
670 s = i['scroll_panels'].first
671 s.has_key?('panel').should be_true
674 r = Scroll.list.to_json Scroll.list_json_opt
677 i.has_key?('author').should be_true
681 describe '単体取得に於いて' do
683 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
685 context 'つつがなく終わるとき' do
686 it '単体取得オプションを利用している' do
687 Scroll.stub(:show_opt).with(any_args).and_return({})
688 Scroll.should_receive(:show_opt).with(any_args).exactly(1)
689 r = Scroll.show @scroll.id, @author
691 it '閲覧許可を問い合わせている' do
692 Scroll.any_instance.stub(:visible?).with(any_args).and_return(true)
693 Scroll.any_instance.should_receive(:visible?).with(any_args).exactly(1)
694 r = Scroll.show @scroll.id, @author
698 c = Scroll.show @scroll.id, @author
701 context '閲覧許可が出なかったとき' do
702 it '403Forbidden例外を返す' do
703 Scroll.any_instance.stub(:visible?).and_return(false)
705 Scroll.show @scroll.id, @author
706 }.should raise_error(ActiveRecord::Forbidden)
709 context '存在しないスクロールを開こうとしたとき' do
710 it '404RecordNotFound例外を返す' do
712 Scroll.show 110, @author
713 }.should raise_error(ActiveRecord::RecordNotFound)
718 describe '編集取得に於いて' do
720 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
722 context 'つつがなく終わるとき' do
723 it '単体取得オプションを利用している' do
724 Scroll.stub(:show_opt).with(any_args).and_return({})
725 Scroll.should_receive(:show_opt).with(any_args).exactly(1)
726 r = Scroll.edit @scroll.id, @author
728 it '所持判定を問い合わせている' do
729 Scroll.any_instance.stub(:own?).with(any_args).and_return(true)
730 Scroll.any_instance.should_receive(:own?).with(any_args).exactly(1)
731 r = Scroll.edit @scroll.id, @author
735 Scroll.any_instance.stub(:own?).and_return(true)
736 c = Scroll.edit @scroll.id, @author.id
739 context '他人のスクロールを開こうとしたとき' do
740 it '403Forbidden例外を返す' do
741 Scroll.any_instance.stub(:own?).and_return(false)
743 Scroll.edit @scroll.id, @author
744 }.should raise_error(ActiveRecord::Forbidden)
747 context '存在しないスクロールを開こうとしたとき' do
748 it '404RecordNotFound例外を返す' do
750 Scroll.edit 110, @author
751 }.should raise_error(ActiveRecord::RecordNotFound)
755 describe '単体取得オプションに於いて' do
756 it 'includeキーを含んでいる' do
758 r.has_key?(:include).should be_true
761 r = Scroll.show_opt[:include]
762 r.should have(2).items
765 r = Scroll.show_opt[:include]
766 r.has_key?(:author).should be_true
769 r = Scroll.show_opt[:include]
770 r.has_key?(:scroll_panels).should be_true
772 it 'スクコマはコマを含んでいる' do
773 r = Scroll.show_opt[:include]
774 r[:scroll_panels].has_key?(:panel).should be_true
777 describe 'json単体出力オプションに於いて' do
779 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
780 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
781 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
782 @sbt = FactoryGirl.create :speech_balloon_template
783 @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1
784 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
785 @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id
788 r = Scroll.show(@scroll.id, @author).to_json Scroll.show_json_opt
791 i.has_key?('scroll_panels').should be_true
793 it 'スクコマはコマを含んでいる' do
794 r = Scroll.show(@scroll.id, @author).to_json Scroll.show_json_opt
797 s = i['scroll_panels'].first
798 s.has_key?('panel').should be_true
801 r = Scroll.show(@scroll.id, @author).to_json Scroll.show_json_opt
804 i.has_key?('author').should be_true
810 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
811 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
812 @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id
813 @other_scroll = FactoryGirl.create :scroll, :author_id => @author.id
814 @other_scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @other_scroll.id, :panel_id => @panel.id
816 context 'つつがなく終わるとき' do
819 r = @scroll.destroy_with_scroll_panel
820 }.should change(Scroll, :count).by(-1)
822 r = Scroll.find @scroll.id
825 it '自身にリンクしているスクコマをすべて削除する' do
827 r = @scroll.destroy_with_scroll_panel
828 }.should change(ScrollPanel, :count).by(-1)
830 r = ScrollPanel.find @scroll_panel.id
834 r = @scroll.destroy_with_scroll_panel
838 context '削除に失敗したとき' do
840 ScrollPanel.any_instance.stub(:destroy).with(any_args).and_return(false)
843 r = @scroll.destroy_with_scroll_panel
848 r = @scroll.destroy_with_scroll_panel
849 }.should_not change(Scroll, :count)
851 r = @scroll.destroy_with_scroll_panel
852 }.should_not change(ScrollPanel, :count)