From 772d0241d99111e97e7a80f1ce107a74668628ad Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Tue, 4 Oct 2011 18:10:25 -0700 Subject: [PATCH] moar tests --- spec/lib/stream/tag_stream_spec.rb | 22 ++++++++++++++++++++++ spec/shared_behaviors/stream.rb | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/spec/lib/stream/tag_stream_spec.rb b/spec/lib/stream/tag_stream_spec.rb index 8b99e037c..deff89821 100644 --- a/spec/lib/stream/tag_stream_spec.rb +++ b/spec/lib/stream/tag_stream_spec.rb @@ -10,4 +10,26 @@ describe TagStream do describe 'shared behaviors' do it_should_behave_like 'it is a stream' end + + describe '.can_comment?' do + before do + @stream = TagStream.new(alice) + @stream.stub(:people).and_return([bob.person]) + end + + it 'returns true if user is a contact of the post author' do + post = Factory(:status_message, :author => bob.person) + @stream.can_comment?(post).should be_true + end + + it 'returns true if a user is the author of the post' do + post = Factory(:status_message, :author => alice.person) + @stream.can_comment?(post).should be_true + end + + it 'returns false otherwise' do + post = Factory(:status_message, :author => eve.person) + @stream.can_comment?(post).should be_false + end + end end diff --git a/spec/shared_behaviors/stream.rb b/spec/shared_behaviors/stream.rb index 01af8b497..ea90a5513 100644 --- a/spec/shared_behaviors/stream.rb +++ b/spec/shared_behaviors/stream.rb @@ -40,6 +40,10 @@ describe 'Streams' do @stream.order=nil @stream.order.should == 'created_at' end + + it 'should have can_comment?(post)' do + @stream.can_comment?(Factory(:status_message)).should_not be_nil + end end end end