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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
require "spec_helper"
describe User::SocialActions do
before do
@bobs_aspect = bob.aspects.where(:name => "generic").first
@status = bob.post(:status_message, :text => "hello", :to => @bobs_aspect.id)
end
describe 'User#comment!' do
it "sets the comment text" do
alice.comment!(@status, "unicorn_mountain").text.should == "unicorn_mountain"
end
it "creates a partcipation" do
lambda{ alice.comment!(@status, "bro") }.should change(Participation, :count).by(1)
alice.participations.last.target.should == @status
end
it "creates the like" do
lambda{ alice.comment!(@status, "bro") }.should change(Comment, :count).by(1)
end
it "federates" do
Participation::Generator.any_instance.stub(:create!)
Postzord::Dispatcher.should_receive(:defer_build_and_post)
alice.comment!(@status, "omg")
end
end
describe 'User#like!' do
it "creates a partcipation" do
lambda{ alice.like!(@status) }.should change(Participation, :count).by(1)
alice.participations.last.target.should == @status
end
it "creates the like" do
lambda{ alice.like!(@status) }.should change(Like, :count).by(1)
end
it "federates" do
#participation and like
Participation::Generator.any_instance.stub(:create!)
Postzord::Dispatcher.should_receive(:defer_build_and_post)
alice.like!(@status)
end
end
describe 'User#like!' do
before do
@bobs_aspect = bob.aspects.where(:name => "generic").first
@status = bob.post(:status_message, :text => "hello", :to => @bobs_aspect.id)
end
it "creates a partcipation" do
lambda{ alice.like!(@status) }.should change(Participation, :count).by(1)
end
it "creates the like" do
lambda{ alice.like!(@status) }.should change(Like, :count).by(1)
end
it "federates" do
#participation and like
Postzord::Dispatcher.should_receive(:defer_build_and_post).twice
alice.like!(@status)
end
it "should be able to like on one's own status" do
like = alice.like!(@status)
@status.reload.likes.first.should == like
end
it "should be able to like on a contact's status" do
like = bob.like!(@status)
@status.reload.likes.first.should == like
end
it "does not allow multiple likes" do
alice.like!(@status)
likes = @status.likes
expect { alice.like!(@status) }.to raise_error
@status.reload.likes.should == likes
end
end
end
|