blob: 6e5dfbf57c907a9ea993c7f739b71b0c4862e98b (
plain)
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
|
# 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 Request do
let(:user) { Factory(:user) }
let(:user2) { Factory :user}
let(:person) {Factory :person}
let(:aspect) { user.aspect(:name => "dudes") }
let(:request){ user.send_friend_request_to user2.person, aspect }
it 'should require a destination and callback url' do
person_request = Request.new
person_request.valid?.should be false
person_request.destination_url = "http://google.com/"
person_request.callback_url = "http://foob.com/"
person_request.valid?.should be true
end
it 'should generate xml for the User as a Person' do
request = user.send_friend_request_to person, aspect
xml = request.to_xml.to_s
xml.should include user.person.diaspora_handle
xml.should include user.person.url
xml.should include user.profile.first_name
xml.should include user.profile.last_name
xml.should include user.exported_key
end
it 'should strip the destination url' do
person_request = Request.new
person_request.destination_url = " http://google.com/ "
person_request.send(:clean_link)
person_request.destination_url.should == "http://google.com/"
end
describe '#request_from_me' do
it 'recognizes requests from me' do
request
user.reload
user.request_from_me?(request).should be true
end
it 'recognized when a request is not from me' do
deliverable = Object.new
deliverable.stub!(:deliver)
Notifier.stub!(:new_request).and_return(deliverable)
user2.receive_salmon(user.salmon(request).xml_for(user2.person))
user2.reload
user2.request_from_me?(request).should == false
end
end
context 'quering request through user' do
it 'finds requests for that user' do
deliverable = Object.new
deliverable.stub!(:deliver)
Notifier.stub!(:new_request).and_return(deliverable)
user2.receive_salmon(user.salmon(request).xml_for(user2.person))
user2.reload
user2.requests_for_me.include?(request).should == true
end
end
end
|