diff options
author | Ilya Zhitomirskiy <iz268@nyu.edu> | 2011-10-20 05:53:05 +0400 |
---|---|---|
committer | danielgrippi <danielgrippi@gmail.com> | 2011-10-25 01:11:35 +0400 |
commit | 1ccf965194530962f7640d4351cbc4a98a02d413 (patch) | |
tree | ce9d848edc05a89e78a663f83cbbcdaa0b363af7 /spec | |
parent | ee74948863996bd3056f9620bedd794eea709fca (diff) |
publisher lib, prefill, open, still need to do public first message for new users
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/publisher_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/stream/aspect_spec.rb | 63 | ||||
-rw-r--r-- | spec/lib/stream/tag_spec.rb | 8 |
3 files changed, 73 insertions, 2 deletions
diff --git a/spec/lib/publisher_spec.rb b/spec/lib/publisher_spec.rb index 0c2a6fb1f..4be5485ce 100644 --- a/spec/lib/publisher_spec.rb +++ b/spec/lib/publisher_spec.rb @@ -21,11 +21,11 @@ describe Publisher do describe "#prefill" do it 'defaults to nothing' do - @publisher.prefill_text.should be_blank + @publisher.prefill.should be_blank end it 'is settable' do - Publisher.new(alice, :prefill_text => "party!").prefill_text.should == "party!" + Publisher.new(alice, :prefill => "party!").prefill.should == "party!" end end diff --git a/spec/lib/stream/aspect_spec.rb b/spec/lib/stream/aspect_spec.rb index b7e96e52c..ef2dedfc8 100644 --- a/spec/lib/stream/aspect_spec.rb +++ b/spec/lib/stream/aspect_spec.rb @@ -172,4 +172,67 @@ describe Stream::Aspect do end it_should_behave_like 'it is a stream' end + + describe "#publisher" do + before do + @stream = Stream::Aspect.new(alice, alice.aspects.map(&:id)) + @stream.stub(:welcome?).and_return(false) + end + + it 'does not use prefill text by default' do + @stream.should_not_receive(:publisher_prefill) + + @stream.publisher + end + + it 'checks welcome?' do + @stream.should_receive(:welcome?).and_return(true) + + @stream.publisher + end + + it 'creates a welcome publisher for new user' do + @stream.stub(:welcome?).and_return(true) + @stream.should_receive(:publisher_prefill).and_return("abc") + + Publisher.should_receive(:new).with(alice, hash_including(:open => true, :prefill => "abc", :public => true)) + @stream.publisher + end + + it 'creates a default publisher for returning users' do + Publisher.should_receive(:new).with(alice) + @stream.publisher + end + end + + describe "#publisher_prefill" do + before do + @tag = ActsAsTaggableOn::Tag.find_or_create_by_name("cats") + @tag_following = alice.tag_followings.create(:tag_id => @tag.id) + + @stream = Stream::Aspect.new(alice, alice.aspects.map(&:id)) + end + + it 'returns includes new user hashtag' do + @stream.send(:publisher_prefill).include?("#newhere").should be_true + end + + it 'includes followed hashtags' do + @stream.send(:publisher_prefill).include?("#cats").should be_true + end + end + + describe "#welcome?" do + it 'returns true if user is getting started' do + alice.getting_started = true + + Stream::Aspect.new(alice, alice.aspects.map(&:id)).send(:welcome?).should be_true + end + + it 'returns false if user is getting started' do + alice.getting_started = false + + Stream::Aspect.new(alice, alice.aspects.map(&:id)).send(:welcome?).should be_false + end + end end diff --git a/spec/lib/stream/tag_spec.rb b/spec/lib/stream/tag_spec.rb index 5a585dd90..4d9cbd08f 100644 --- a/spec/lib/stream/tag_spec.rb +++ b/spec/lib/stream/tag_spec.rb @@ -91,4 +91,12 @@ describe Stream::Tag do stream.tag_name.should == 'what' end end + + describe "#publisher" do + it 'creates a publisher with the tag prefill' do + Publisher.should_receive(:new).with(anything(), hash_including(:prefill => "#what ")) + @stream = Stream::Tag.new(alice, "what") + @stream.publisher + end + end end |