Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authordanielvincent <danielgrippi@gmail.com>2010-10-30 06:13:09 +0400
committermaxwell <maxwell@joindiaspora.com>2010-11-02 00:54:40 +0300
commitf6b4be97a3801b9975f4838ad40471e6db6eb5f3 (patch)
tree5ef0185d9608c4598ceffbc23225c296695666e9 /spec
parent1acc206fa47afd17018d0af0a136b2c367e8c854 (diff)
requests are almost there
Diffstat (limited to 'spec')
-rw-r--r--spec/helper_methods.rb5
-rw-r--r--spec/lib/diaspora/parser_spec.rb35
-rw-r--r--spec/models/request_spec.rb35
-rw-r--r--spec/models/user/user_friending_spec.rb13
4 files changed, 49 insertions, 39 deletions
diff --git a/spec/helper_methods.rb b/spec/helper_methods.rb
index e60b39535..4dc1ca8f2 100644
--- a/spec/helper_methods.rb
+++ b/spec/helper_methods.rb
@@ -28,9 +28,12 @@ module HelperMethods
def friend_users(user1, aspect1, user2, aspect2)
request = user1.send_friend_request_to(user2.person, aspect1)
- user2.receive_friend_request(request)
+
+ user2.receive request.to_diaspora_xml, user1.person
+
reversed_request = user2.accept_friend_request( request.id, aspect2.id)
user1.reload
+
user1.receive reversed_request.to_diaspora_xml, user2.person
user1.reload
aspect1.reload
diff --git a/spec/lib/diaspora/parser_spec.rb b/spec/lib/diaspora/parser_spec.rb
index 6e7d74109..fc2a021fa 100644
--- a/spec/lib/diaspora/parser_spec.rb
+++ b/spec/lib/diaspora/parser_spec.rb
@@ -35,6 +35,8 @@ describe Diaspora::Parser do
end
context "friending" do
+
+ let(:good_request) { FakeHttpRequest.new(:success)}
before do
deliverable = Object.new
deliverable.stub!(:deliver)
@@ -42,30 +44,24 @@ describe Diaspora::Parser do
end
it "should create a new person upon getting a person request" do
+ webfinger_mock = EMWebfinger.new(person.diaspora_handle)
+ webfinger_mock.should_receive(:on_person)
+
+ EMWebfinger.should_receive(:new).and_return(webfinger_mock)
+
+
request = Request.instantiate(:to =>"http://www.google.com/", :from => person)
xml = request.to_diaspora_xml
- user3.destroy
- person.destroy
+ user3.delete
+ person.delete
+ Person.should_receive(:by_account_identifier).exactly(2).times.and_return(person)
user
lambda { user.receive xml, person }.should change(Person, :count).by(1)
end
- it "should not create a new person if the person is already here" do
- request = Request.instantiate(:to =>"http://www.google.com/", :from => user2.person)
- original_person_id = user2.person.id
- xml = request.to_diaspora_xml
- user
- lambda { user.receive xml, user2.person }.should_not change(Person, :count)
- user2.reload
- user2.person.reload
- user2.serialized_private_key.include?("PRIVATE").should be true
-
- url = "http://" + request.callback_url.split("/")[2] + "/"
- Person.where(:url => url).first.id.should == original_person_id
- end
end
it "should activate the Person if I initiated a request to that url" do
@@ -73,13 +69,12 @@ describe Diaspora::Parser do
user.reload
request.reverse_for user3
- xml = request.to_diaspora_xml
+ xml = user3.salmon(request).xml_for(user.person)
- user3.person.destroy
- user3.destroy
+ user3.delete
- user.receive xml, user3.person
- new_person = Person.first(:url => user3.person.url)
+ user.receive_salmon(xml)
+ new_person = Person.find_by_url(user3.person.url)
new_person.nil?.should be false
user.reload
diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb
index e08347d69..daab156b7 100644
--- a/spec/models/request_spec.rb
+++ b/spec/models/request_spec.rb
@@ -19,17 +19,6 @@ describe Request do
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
@@ -68,4 +57,28 @@ describe Request do
end
end
+ describe 'serialization' do
+ it 'should not 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_not include user.person.profile.first_name
+ end
+
+ it 'should serialize the handle and not the sender' do
+ request = user.send_friend_request_to person, aspect
+ xml = request.to_xml.to_s
+
+ xml.should include user.person.diaspora_handle
+ end
+
+ it 'should not serialize the exported key' do
+ request = user.send_friend_request_to person, aspect
+ xml = request.to_xml.to_s
+
+ xml.should_not include user.person.exported_key
+ end
+
+ end
+
end
diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb
index 945f3dcbf..a1232b80b 100644
--- a/spec/models/user/user_friending_spec.rb
+++ b/spec/models/user/user_friending_spec.rb
@@ -233,23 +233,22 @@ describe Diaspora::UserModules::Friending do
end
it "keeps the right counts of friends" do
- user.receive_friend_request @request
+ user.receive @request.to_diaspora_xml, person_one
- person_two.destroy
- user.reload.pending_requests.size.should be 1
+ user.reload.pending_requests.size.should == 1
user.friends.size.should be 0
- user.receive_friend_request @request_two
- user.reload.pending_requests.size.should be 2
+ user.receive @request_two.to_diaspora_xml, person_two
+ user.reload.pending_requests.size.should == 2
user.friends.size.should be 0
user.accept_friend_request @request.id, aspect.id
- user.reload.pending_requests.size.should be 1
+ user.reload.pending_requests.size.should == 1
user.friends.size.should be 1
user.contact_for(person_one).should_not be_nil
user.ignore_friend_request @request_two.id
- user.reload.pending_requests.size.should be 0
+ user.reload.pending_requests.size.should == 0
user.friends.size.should be 1
user.contact_for(person_two).should be_nil
end