« git@code.facil.services:facil/parlote-facil.git » n'existait pas sur « dc12479070c75ddbf59f3cd8b57037bed537713c »
Newer
Older
MrZYX
a validé
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
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
describe LikesController do
render_views
before do
@user1 = alice
@user2 = bob
@aspect1 = @user1.aspects.first
@aspect2 = @user2.aspects.first
sign_in :user, @user1
end
describe '#create' do
let(:like_hash) {
{:positive => 1,
:post_id => "#{@post.id}"}
}
let(:dislike_hash) {
{:positive => 0,
:post_id => "#{@post.id}"}
}
context "on my own post" do
before do
@post = @user1.post :status_message, :text => "AWESOME", :to => @aspect1.id
end
it 'responds to format js' do
post :create, like_hash.merge(:format => 'js')
response.code.should == '201'
end
end
context "on a post from a contact" do
before do
@post = @user2.post :status_message, :text => "AWESOME", :to => @aspect2.id
end
it 'likes' do
post :create, like_hash
response.code.should == '201'
end
it 'dislikes' do
post :create, dislike_hash
response.code.should == '201'
end
it "doesn't post multiple times" do
@user1.like(1, :on => @post)
post :create, dislike_hash
response.code.should == '422'
end
end
context "on a post from a stranger" do
before do
@post = eve.post :status_message, :text => "AWESOME", :to => eve.aspects.first.id
end
it "doesn't post" do
@user1.should_not_receive(:like)
post :create, like_hash
response.code.should == '422'
end
end
end
end