Newer
Older
require 'spec_helper'
require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
describe Stream::Multi do
@stream = Stream::Multi.new(Factory(:user), :max_time => Time.now, :order => 'updated_at')
Maxwell Salzberg
a validé
describe 'shared behaviors' do
it_should_behave_like 'it is a stream'
end
Maxwell Salzberg
a validé
describe '#is_in?' do
it 'handles when the cache returns strings' do
p = Factory(:status_message)
@stream.should_receive(:aspects_post_ids).and_return([p.id.to_s])
@stream.send(:is_in?, :aspects, p).should be_true
end
end
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
describe '#publisher_opts' do
it 'prefills, sets public, and autoexpands if welcome? is set' do
prefill_text = "sup?"
@stream.stub(:welcome?).and_return(true)
@stream.stub(:publisher_prefill).and_return(prefill_text)
@stream.send(:publisher_opts).should == {:open => true,
:prefill => prefill_text,
:public => true}
end
it 'provides no opts if welcome? is not set' do
prefill_text = "sup?"
@stream.stub(:welcome?).and_return(false)
@stream.send(:publisher_opts).should == {}
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::Multi.new(alice)
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
before do
@stream = Stream::Multi.new(alice)
end
it 'returns true if user is getting started' do
alice.getting_started = true
@stream.send(:welcome?).should be_true
end
it 'returns false if user is getting started' do
alice.getting_started = false
@stream.send(:welcome?).should be_false
end
end