before do
@pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
end
- context '検査対象がnil(ゲスト)のとき' do
- context 'クローズドモードのとき' do
- before do
- MagicNumber['run_mode'] = 1
- end
- it '不許可を返す。' do
- r = @pc.visible?(nil)
- r.should be_false
- end
- end
- context 'オープンモードのとき' do
- before do
- MagicNumber['run_mode'] = 0
- end
- it '公開されたコマの指定色地なら許可する' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(true)
- r = @pc.visible?(nil)
- r.should be_true
- end
- it 'れ以外なら不許可を返す' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @pc.visible?(nil)
- r.should be_false
- end
- end
- end
- context '検査対象が作家のとき' do
- it '公開されたコマの指定色地なら許可する' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(true)
- r = @pc.visible?(@author)
- r.should be_true
+ context 'オープンモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 0
+ end
+ it '自身にゲスト用ロールチェックを問い合わせしている' do
+ PanelColor.any_instance.stub(:guest_role_check).and_return(true)
+ PanelColor.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)
+ r = @pc.visible?([@author])
end
- it 'ã\82\8c以å¤\96ã\81ªã\82\89ä¸\8d許å\8f¯を返す' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @pc.visible?(@author)
+ it 'ã\82²ã\82¹ã\83\88ç\94¨ã\83ã\83¼ã\83«ã\83\81ã\82§ã\83\83ã\82¯ã\81\8c失æ\95\97ã\81\97ã\81\9fã\81¨ã\81\8dã\80\81falseを返す' do
+ PanelColor.any_instance.stub(:guest_role_check).and_return(false)
+ r = @pc.visible?([@author])
r.should be_false
end
end
- context '検査対象が管理者のとき' do
- it '許可を返す。' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @pc.visible?(@admin)
- r.should be_true
+ context 'クローズドモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ end
+ it '自身に読者用ロールチェックを問い合わせしている' do
+ PanelColor.any_instance.stub(:reader_role_check).and_return(true)
+ PanelColor.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1)
+ r = @pc.visible?([@author])
+ end
+ it '読者用ロールチェックが失敗したとき、falseを返す' do
+ PanelColor.any_instance.stub(:reader_role_check).and_return(false)
+ r = @pc.visible?([@author])
+ r.should be_false
+ end
+ end
+ context '事前チェックする' do
+ before do
+ MagicNumber['run_mode'] = 1
+ PanelColor.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ it '自身のコマに所持判定を問い合わせしている' do
+ Panel.any_instance.stub(:own?).and_return(true)
+ Panel.any_instance.should_receive(:own?).with(any_args).exactly(1)
+ r = @pc.visible?([@author])
+ end
+ it '自身のコマに閲覧許可を問い合わせしている' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(true)
+ Panel.any_instance.should_receive(:visible?).with(any_args).exactly(1)
+ r = @pc.visible?([@author])
end
end
- context '検査対象がそれ以外のとき' do
- it '不許可を返す。' do
- r = @pc.visible?(1)
+ context 'つつがなく終わるとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ Panel.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ it '自分のコマの指定色地なら許可する' do
+ Panel.any_instance.stub(:own?).and_return(true)
+ Panel.any_instance.stub(:visible?).and_return(false)
+ r = @pc.visible?([@author])
+ r.should be_true
+ end
+ it '他人の非公開コマの指定色地なら許可しない' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(false)
+ r = @pc.visible?([@author])
r.should be_false
end
+ it '他人のコマの指定色地でも公開なら許可する' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(true)
+ r = @pc.visible?([@author])
+ r.should be_true
+ end
end
end