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
65 describe '文字コード検証に於いて' do
67 @scroll = FactoryGirl.build :scroll, :author_id => @author.id
70 context 'titleを検証するとき' do
71 it 'Shift JISなら失敗する' do
72 @scroll.title = "\x83G\x83r\x83]\x83D"
75 }.should raise_error(Pettanr::BadRequest)
79 context 'descriptionを検証するとき' do
80 it 'Shift JISなら失敗する' do
81 @scroll.description = "\x83G\x83r\x83]\x83D"
84 }.should raise_error(Pettanr::BadRequest)
89 describe 'デフォルト値補充に於いて' do
90 it 'visibleが0になっている' do
91 @scroll = FactoryGirl.build :scroll, :visible => nil
92 @scroll.supply_default
93 @scroll.visible.should eq 0
97 describe '上書き補充に於いて' do
99 @scroll = FactoryGirl.build :scroll, :author_id => nil
100 @scroll.overwrite @author
101 @scroll.author_id.should eq @author.id
105 describe 'ロールリストからの作家取得に於いて' do
106 context 'ロールがユーザのとき' do
107 it 'ユーザから作家を取得して、それを返す' do
108 r = Scroll.get_author_from_roles([@user])
112 context 'ロールが作家のとき' do
114 r = Scroll.get_author_from_roles([@author])
118 context 'ロールが絵師のとき' do
119 it '絵師から作家を取得できれば、それをを返す' do
120 r = Scroll.get_author_from_roles([@artist])
123 it '絵師から作家を取得できないときnilを返す' do
124 @artist.author_id = nil
126 r = Scroll.get_author_from_roles([@artist])
130 context 'ロールが管理者のとき' do
132 r = Scroll.get_author_from_roles([@admin])
138 describe 'ロールリストからの絵師取得に於いて' do
139 context 'ロールがユーザのとき' do
140 it 'ユーザから作家を取得して、そこから絵師を取得できれば、それを返す' do
141 r = Scroll.get_artist_from_roles([@user])
144 it '作家から絵師を取得できないときnilを返す' do
145 @artist.author_id = nil
147 r = Scroll.get_artist_from_roles([@user])
151 context 'ロールが作家のとき' do
152 it 'そこから絵師を取得できれば、それを返す' do
153 r = Scroll.get_artist_from_roles([@author])
156 it '作家から絵師を取得できないときnilを返す' do
157 @artist.author_id = nil
159 r = Scroll.get_artist_from_roles([@author])
163 context 'ロールが絵師のとき' do
165 r = Scroll.get_artist_from_roles([@artist])
169 context 'ロールが管理者のとき' do
171 r = Scroll.get_artist_from_roles([@admin])
177 describe '所持判定に於いて' do
179 @scroll = FactoryGirl.build :scroll, :author_id => @author.id
181 context '事前チェックする' do
182 it '自身にロールリストからの作家取得を依頼している' do
183 Scroll.should_receive(:get_author_from_roles).with(any_args).exactly(1)
184 r = @scroll.own?([@author])
187 context 'ロール内作家が取得できるとき' do
190 it 'ロール内作家のidが自身の作家idと一致するなら許可する' do
191 Scroll.stub(:get_author_from_roles).with(any_args).and_return(@author)
192 r = @scroll.own?([@author])
195 it 'ロール内作家のidが自身の作家idと一致しないならno' do
196 Scroll.stub(:get_author_from_roles).with(any_args).and_return(@other_author)
197 @scroll.own?(@other_author).should be_false
200 context 'ロール内作家が取得できないとき' do
202 Scroll.stub(:get_author_from_roles).with(any_args).and_return(nil)
205 r = @scroll.own?([@author])
211 describe '読者用ロールチェックに於いて' do
213 @scroll = FactoryGirl.build :scroll, :author_id => @author.id
215 context 'ロールリストに作家が含まれるとき' do
216 it 'ロールリストがリストではないとき、リストにする trueを返す' do
217 r = @scroll.reader_role_check(@author)
221 r = @scroll.reader_role_check([@author])
225 context 'ロールリストに絵師が含まれるとき' do
227 r = @scroll.reader_role_check([@artist])
231 context 'ロールリストにユーザが含まれるとき' do
233 r = @scroll.reader_role_check([@user])
237 context 'ロールリストに管理者が含まれるとき' do
239 r = @scroll.reader_role_check([@admin])
243 context 'ロールリストにユーザ、管理者、作家、絵師が含まれないとき' do
245 r = @scroll.reader_role_check([nil])
251 describe '素材読者用ロールチェックに於いて' do
253 @scroll = FactoryGirl.build :scroll, :author_id => @author.id
255 context 'ロールリストに作家が含まれるとき' do
256 it 'ロールリストがリストではないとき、リストにする trueを返す' do
257 r = @scroll.resource_reader_role_check(@author)
261 r = @scroll.resource_reader_role_check([@author])
265 context 'ロールリストに絵師が含まれるとき' do
267 r = @scroll.resource_reader_role_check([@artist])
271 context 'ロールリストにユーザが含まれるとき' do
273 r = @scroll.resource_reader_role_check([@user])
277 context 'ロールリストに管理者が含まれるとき' do
279 r = @scroll.resource_reader_role_check([@admin])
283 context 'ロールリストに借手が含まれるとき' do
285 r = @scroll.resource_reader_role_check([@demand_user])
289 context 'ロールリストにユーザ、管理者、作家、絵師、借手が含まれないとき' do
291 r = @scroll.resource_reader_role_check([nil])
297 describe '閲覧許可に於いて' do
299 @scroll = FactoryGirl.build :scroll, :author_id => @author.id
301 context 'オープンモードのとき' do
303 MagicNumber['run_mode'] = 0
305 it '自身にゲスト用ロールチェックを問い合わせしている' do
306 Scroll.any_instance.stub(:guest_role_check).and_return(true)
307 Scroll.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)
308 r = @scroll.visible?([@author])
310 it 'ゲスト用ロールチェックが失敗したとき、falseを返す' do
311 Scroll.any_instance.stub(:guest_role_check).and_return(false)
312 r = @scroll.visible?([@author])
316 context 'クローズドモードのとき' do
318 MagicNumber['run_mode'] = 1
320 it '自身に読者用ロールチェックを問い合わせしている' do
321 Scroll.any_instance.stub(:reader_role_check).and_return(true)
322 Scroll.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1)
323 r = @scroll.visible?([@author])
325 it '読者用ロールチェックが失敗したとき、falseを返す' do
326 Scroll.any_instance.stub(:reader_role_check).and_return(false)
327 r = @scroll.visible?([@author])
331 context '事前チェックする' do
333 MagicNumber['run_mode'] = 1
334 Scroll.any_instance.stub(:reader_role_check).and_return(true)
335 Scroll.any_instance.stub(:own?).and_return(true)
337 it '自身に所持判定を問い合わせしている' do
338 Scroll.any_instance.should_receive(:own?).with(any_args).exactly(1)
339 r = @scroll.visible?([@author])
342 context 'つつがなく終わるとき' do
344 MagicNumber['run_mode'] = 1
345 Scroll.any_instance.stub(:reader_role_check).and_return(true)
347 it '自分のスクロールなら許可する' do
348 Scroll.any_instance.stub(:own?).and_return(true)
349 Scroll.any_instance.stub(:visible).and_return(0)
350 r = @scroll.visible?([@author])
353 it '他人の非公開スクロールなら許可しない' do
354 Scroll.any_instance.stub(:own?).and_return(false)
355 Scroll.any_instance.stub(:visible).and_return(0)
356 r = @scroll.visible?([@author])
359 it '他人のスクロールでも公開なら許可する' do
360 Scroll.any_instance.stub(:own?).and_return(false)
361 Scroll.any_instance.stub(:visible).and_return(1)
362 r = @scroll.visible?([@author])
368 describe '一覧取得に於いて' do
370 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
372 context 'page補正について' do
373 it '文字列から数値に変換される' do
374 Scroll.page('8').should eq 8
377 Scroll.page().should eq 1
380 Scroll.page('0').should eq 1
383 context 'page_size補正について' do
384 it '文字列から数値に変換される' do
385 Scroll.page_size('7').should eq 7
387 it 'nilの場合はScroll.default_page_sizeになる' do
388 Scroll.page_size().should eq Scroll.default_page_size
390 it '0以下の場合はScroll.default_page_sizeになる' do
391 Scroll.page_size('0').should eq Scroll.default_page_size
393 it 'Scroll.max_page_sizeを超えた場合はScroll.max_page_sizeになる' do
394 Scroll.page_size('1000').should eq Scroll.max_page_size
397 context 'つつがなく終わるとき' do
398 it '一覧取得オプションを利用している' do
399 Scroll.stub(:list_opt).with(any_args).and_return({})
400 Scroll.should_receive(:list_opt).with(any_args).exactly(1)
406 c.should eq [@scroll]
408 it '非公開スクロールは(自分のスクロールであっても)含んでいない' do
409 FactoryGirl.create :scroll, :author_id => @author.id, :visible => 0
411 c.should eq [@scroll]
414 #公開スクロールは(他人のスクロールであっても)含んでいる
415 v = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 100
417 c.should eq [v, @scroll]
419 context 'DBに5件あって1ページの件数を2件に変えたとして' do
421 @scroll2 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 100
422 @scroll3 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 200
423 @scroll4 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 300
424 @scroll5 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 400
425 Scroll.stub(:default_page_size).and_return(2)
429 c.should have(2).items
431 it 'page=1なら末尾2件を返す' do
434 c.should eq [@scroll5, @scroll4]
436 it 'page=2なら中間2件を返す' do
438 c.should eq [@scroll3, @scroll2]
440 it 'page=3なら先頭1件を返す' do
442 c.should eq [@scroll]
447 describe '自分のスクロール一覧取得に於いて' do
449 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
451 context 'つつがなく終わるとき' do
452 it '一覧取得オプションを利用している' do
453 Scroll.stub(:list_opt).with(any_args).and_return({})
454 Scroll.should_receive(:list_opt).with(any_args).exactly(1)
455 r = Scroll.mylist @author
459 c = Scroll.mylist @author
460 c.should eq [@scroll]
463 nc = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 100
464 cl = Scroll.mylist @author
465 cl.should eq [nc, @scroll]
467 it '他人のスクロールは公開でも含まない' do
468 nc = FactoryGirl.create :scroll, :author_id => @other_author.id, :visible => 1
469 cl = Scroll.mylist @author
470 cl.should eq [@scroll]
472 it '自分のスクロールは非公開でも含んでいる' do
473 nc = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 0, :updated_at => Time.now + 100
474 cl = Scroll.mylist @author
475 cl.should eq [nc, @scroll]
477 context 'DBに5件あって1ページの件数を2件に変えたとして' do
479 @scroll2 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 100
480 @scroll3 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 200
481 @scroll4 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 300
482 @scroll5 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 400
485 c = Scroll.mylist @author, 1, 2
486 c.should have(2).items
488 it 'page=1なら末尾2件を返す' do
490 c = Scroll.mylist(@author, 1, 2)
491 c.should eq [@scroll5, @scroll4]
493 it 'page=2なら中間2件を返す' do
494 c = Scroll.mylist(@author, 2, 2)
495 c.should eq [@scroll3, @scroll2]
497 it 'page=3なら先頭1件を返す' do
498 c = Scroll.mylist(@author, 3, 2)
499 c.should eq [@scroll]
504 describe '他作家のスクロール一覧取得に於いて' do
506 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
507 @other_scroll = FactoryGirl.create :scroll, :author_id => @other_author.id, :visible => 1
509 context 'つつがなく終わるとき' do
510 it '一覧取得オプションを利用している' do
511 Scroll.stub(:list_opt).with(any_args).and_return({})
512 Scroll.should_receive(:list_opt).with(any_args).exactly(1)
513 r = Scroll.himlist @other_author
516 it '指定した作家のリストを返す' do
517 r = Scroll.himlist @other_author
518 r.should eq [@other_scroll]
521 nc = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 100
522 r = Scroll.himlist @other_author
523 r.should eq [nc, @other_scroll]
526 hidden = FactoryGirl.create :scroll, :author_id => @other_author.id, :visible => 0
527 r = Scroll.himlist @other_author
528 r.should eq [@other_scroll]
530 context 'DBに5件あって1ページの件数を2件に変えたとして' do
532 @other_scroll2 = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 100
533 @other_scroll3 = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 200
534 @other_scroll4 = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 300
535 @other_scroll5 = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 400
538 c = Scroll.himlist @other_author, 1, 2
539 c.should have(2).items
541 it 'page=1なら末尾2件を返す' do
543 c = Scroll.himlist(@other_author, 1, 2)
544 c.should eq [@other_scroll5, @other_scroll4]
546 it 'page=2なら中間2件を返す' do
547 c = Scroll.himlist(@other_author, 2, 2)
548 c.should eq [@other_scroll3, @other_scroll2]
550 it 'page=3なら先頭1件を返す' do
551 c = Scroll.himlist(@other_author, 3, 2)
552 c.should eq [@other_scroll]
557 describe 'スクロール一覧ページ制御に於いて' do
559 Scroll.stub(:count).with(any_args).and_return(100)
562 r = Scroll.list_paginate
563 r.is_a?(Kaminari::PaginatableArray).should be_true
565 it 'スクロール一覧の取得条件を利用している' do
566 Scroll.stub(:list_where).with(any_args).and_return('')
567 Scroll.should_receive(:list_where).with(any_args).exactly(1)
568 r = Scroll.list_paginate
570 it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
571 r = Scroll.list_paginate 3, 10
572 r.limit_value.should eq 10
573 r.offset_value.should eq 20
577 describe '自分のスクロール一覧ページ制御に於いて' do
579 Scroll.stub(:count).with(any_args).and_return(100)
582 r = Scroll.mylist_paginate @author
583 r.is_a?(Kaminari::PaginatableArray).should be_true
585 it '自分のスクロール一覧の取得条件を利用している' do
586 Scroll.stub(:mylist_where).with(any_args).and_return('')
587 Scroll.should_receive(:mylist_where).with(any_args).exactly(1)
588 r = Scroll.mylist_paginate @author
590 it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
591 r = Scroll.mylist_paginate @author, 3, 10
592 r.limit_value.should eq 10
593 r.offset_value.should eq 20
597 describe '他作家のスクロール一覧ページ制御に於いて' do
599 Scroll.stub(:count).with(any_args).and_return(100)
602 r = Scroll.himlist_paginate @other_author
603 r.is_a?(Kaminari::PaginatableArray).should be_true
605 it '他作家のスクロール一覧の取得条件を利用している' do
606 Scroll.stub(:himlist_where).with(any_args).and_return('')
607 Scroll.should_receive(:himlist_where).with(any_args).exactly(1)
608 r = Scroll.himlist_paginate @other_author
610 it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
611 r = Scroll.himlist_paginate @other_author, 3, 10
612 r.limit_value.should eq 10
613 r.offset_value.should eq 20
617 describe '一覧取得オプションに於いて' do
620 r.should have(2).items
624 r.has_key?(:scroll_panels).should be_true
626 it 'スクコマはコマを含んでいる' do
628 r[:scroll_panels].has_key?(:panel).should be_true
632 r.has_key?(:author).should be_true
635 describe 'json一覧出力オプションに於いて' do
637 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
638 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
639 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
640 @sbt = FactoryGirl.create :speech_balloon_template
641 @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1
642 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
643 @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id
646 r = Scroll.list.to_json Scroll.list_json_opt
649 i.has_key?('scroll_panels').should be_true
651 it 'スクコマはコマを含んでいる' do
652 r = Scroll.list.to_json Scroll.list_json_opt
655 s = i['scroll_panels'].first
656 s.has_key?('panel').should be_true
659 r = Scroll.list.to_json Scroll.list_json_opt
662 i.has_key?('author').should be_true
666 describe '単体取得に於いて' do
668 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
670 context 'つつがなく終わるとき' do
671 it '単体取得オプションを利用している' do
672 Scroll.stub(:show_opt).with(any_args).and_return({})
673 Scroll.should_receive(:show_opt).with(any_args).exactly(1)
674 r = Scroll.show @scroll.id, @author
676 it '閲覧許可を問い合わせている' do
677 Scroll.any_instance.stub(:visible?).with(any_args).and_return(true)
678 Scroll.any_instance.should_receive(:visible?).with(any_args).exactly(1)
679 r = Scroll.show @scroll.id, @author
683 c = Scroll.show @scroll.id, @author
686 context '閲覧許可が出なかったとき' do
687 it '403Forbidden例外を返す' do
688 Scroll.any_instance.stub(:visible?).and_return(false)
690 Scroll.show @scroll.id, @author
691 }.should raise_error(ActiveRecord::Forbidden)
694 context '存在しないスクロールを開こうとしたとき' do
695 it '404RecordNotFound例外を返す' do
697 Scroll.show 110, @author
698 }.should raise_error(ActiveRecord::RecordNotFound)
703 describe '編集取得に於いて' do
705 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
707 context 'つつがなく終わるとき' do
708 it '単体取得オプションを利用している' do
709 Scroll.stub(:show_opt).with(any_args).and_return({})
710 Scroll.should_receive(:show_opt).with(any_args).exactly(1)
711 r = Scroll.edit @scroll.id, @author
713 it '所持判定を問い合わせている' do
714 Scroll.any_instance.stub(:own?).with(any_args).and_return(true)
715 Scroll.any_instance.should_receive(:own?).with(any_args).exactly(1)
716 r = Scroll.edit @scroll.id, @author
720 Scroll.any_instance.stub(:own?).and_return(true)
721 c = Scroll.edit @scroll.id, @author.id
724 context '他人のスクロールを開こうとしたとき' do
725 it '403Forbidden例外を返す' do
726 Scroll.any_instance.stub(:own?).and_return(false)
728 Scroll.edit @scroll.id, @author
729 }.should raise_error(ActiveRecord::Forbidden)
732 context '存在しないスクロールを開こうとしたとき' do
733 it '404RecordNotFound例外を返す' do
735 Scroll.edit 110, @author
736 }.should raise_error(ActiveRecord::RecordNotFound)
740 describe '単体取得オプションに於いて' do
741 it 'includeキーを含んでいる' do
743 r.has_key?(:include).should be_true
746 r = Scroll.show_opt[:include]
747 r.should have(2).items
750 r = Scroll.show_opt[:include]
751 r.has_key?(:author).should be_true
754 r = Scroll.show_opt[:include]
755 r.has_key?(:scroll_panels).should be_true
757 it 'スクコマはコマを含んでいる' do
758 r = Scroll.show_opt[:include]
759 r[:scroll_panels].has_key?(:panel).should be_true
762 describe 'json単体出力オプションに於いて' do
764 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
765 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
766 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
767 @sbt = FactoryGirl.create :speech_balloon_template
768 @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1
769 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
770 @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id
773 r = Scroll.show(@scroll.id, @author).to_json Scroll.show_json_opt
776 i.has_key?('scroll_panels').should be_true
778 it 'スクコマはコマを含んでいる' do
779 r = Scroll.show(@scroll.id, @author).to_json Scroll.show_json_opt
782 s = i['scroll_panels'].first
783 s.has_key?('panel').should be_true
786 r = Scroll.show(@scroll.id, @author).to_json Scroll.show_json_opt
789 i.has_key?('author').should be_true
795 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
796 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
797 @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id
798 @other_scroll = FactoryGirl.create :scroll, :author_id => @author.id
799 @other_scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @other_scroll.id, :panel_id => @panel.id
801 context 'つつがなく終わるとき' do
804 r = @scroll.destroy_with_scroll_panel
805 }.should change(Scroll, :count).by(-1)
807 r = Scroll.find @scroll.id
810 it '自身にリンクしているスクコマをすべて削除する' do
812 r = @scroll.destroy_with_scroll_panel
813 }.should change(ScrollPanel, :count).by(-1)
815 r = ScrollPanel.find @scroll_panel.id
819 r = @scroll.destroy_with_scroll_panel
823 context '削除に失敗したとき' do
825 ScrollPanel.any_instance.stub(:destroy).with(any_args).and_return(false)
828 r = @scroll.destroy_with_scroll_panel
833 r = @scroll.destroy_with_scroll_panel
834 }.should_not change(Scroll, :count)
836 r = @scroll.destroy_with_scroll_panel
837 }.should_not change(ScrollPanel, :count)