forked from diaspora/diaspora
/
reshares_helper_spec.rb
50 lines (42 loc) · 1.37 KB
/
reshares_helper_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
require 'spec_helper'
describe ResharesHelper do
include StreamHelper
describe 'reshare_link' do
it 'does not display a reshare for a post that does not exist' do
reshare = Factory.build(:reshare, :root => nil)
lambda {
reshare_link(reshare)
}.should_not raise_error
end
describe 'for a typical post' do
before :each do
aspect = alice.aspects.first
@post = alice.build_post :status_message, :text => "ohai", :to => aspect.id, :public => true
@post.save!
alice.add_to_streams(@post, [aspect])
alice.dispatch_post @post, :to => aspect.id
end
describe 'which has not been reshared' do
before :each do
@post.reshares_count.should == 0
end
it 'has "Reshare" as the English text' do
reshare_link(@post).should =~ %r{>Reshare</a>}
end
end
describe 'which has been reshared' do
before :each do
@reshare = Factory.create(:reshare, :root => @post)
@post.reload
@post.reshares_count.should == 1
end
it 'has "Reshare" as the English text' do
reshare_link(@post).should =~ %r{>Reshare</a>}
end
it 'its reshare has "Reshare original" as the English text' do
reshare_link(@reshare).should =~ %r{>Reshare original</a>}
end
end
end
end
end