fix comment helper specs

This commit is contained in:
Maxwell Salzberg 2011-10-04 18:57:35 -07:00
parent f98ff61e16
commit 8a5d76de21

View file

@ -22,21 +22,36 @@ describe CommentsHelper do
end
describe 'commenting_disabled?' do
include Devise::TestHelpers
before do
sign_in alice
def user_signed_in?
true
end
end
it 'returns true if no user is signed in' do
def user_signed_in?
false
end
commenting_disabled?(stub).should == true
end
it 'returns true if @commenting_disabled is set' do
@commenting_disabled = true
commenting_disabled?(stub).should_be true
commenting_disabled?(stub).should == true
@commenting_disabled = false
commenting_disabled?(stub).should_be false
commenting_disabled?(stub).should == false
end
it 'returns @stream.can_comment? if @stream is set' do
post = stub
@stream = stub
@stream.should_receive(:can_comment?).with(post).and_return(true)
commenting_disabled?(post).should_be true
commenting_disabled?(post).should == false
@stream.should_receive(:can_comment?).with(post).and_return(false)
commenting_disabled?(post).should_be false
commenting_disabled?(post).should == true
end
end
end