MS IZ request specs now PASS
This commit is contained in:
parent
b9718c079b
commit
a45d852f30
7 changed files with 30 additions and 23 deletions
|
|
@ -40,7 +40,7 @@ class User
|
|||
######### Friend Requesting ###########
|
||||
def send_friend_request_to(friend_url)
|
||||
|
||||
unless self.friends.detect{ |x| x.url == friend_url}
|
||||
unless self.friends.detect{ |x| x.receive_url == friend_url}
|
||||
p = Request.instantiate(:to => friend_url, :from => self.person)
|
||||
if p.save
|
||||
self.pending_requests << p
|
||||
|
|
@ -76,8 +76,7 @@ class User
|
|||
|
||||
def receive_friend_request(friend_request)
|
||||
Rails.logger.debug("receiving friend request #{friend_request.to_json}")
|
||||
|
||||
if Request.where(:callback_url => person.receive_url, :destination_url => person.receive_url).first
|
||||
if pending_requests.detect{|req| (req.callback_url == person.receive_url) && (req.destination_url == person.receive_url)}
|
||||
activate_friend friend_request.person
|
||||
Rails.logger.debug("#{self.real_name}'s friend request has been accepted")
|
||||
friend_request.destroy
|
||||
|
|
|
|||
|
|
@ -60,17 +60,17 @@ module Diaspora
|
|||
objects = parse_objects_from_xml(xml)
|
||||
objects.each do |p|
|
||||
Rails.logger.debug("Receiving object:\n#{p.inspect}")
|
||||
|
||||
if p.is_a? Retraction
|
||||
Rails.logger.debug "Got a retraction for #{p.post_id}"
|
||||
p.perform
|
||||
|
||||
elsif p.is_a? Request
|
||||
puts user.pending_requests.count
|
||||
user.receive_friend_request(p)
|
||||
puts user.pending_requests.count
|
||||
|
||||
elsif p.is_a? Profile
|
||||
p.save
|
||||
|
||||
elsif p.respond_to?(:person) && !(p.person.nil?) && !(p.person.is_a? User)
|
||||
Rails.logger.debug("Saving object with success: #{p.save}")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ describe RequestsHelper do
|
|||
end
|
||||
|
||||
it 'should return the correct tag and url for a given address' do
|
||||
relationship_flow('tom@tom.joindiaspora.com')[:friend].should == 'http://tom.joindiaspora.com/'
|
||||
relationship_flow('tom@tom.joindiaspora.com')[:friend].include?("receive/user").should == true
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|||
include ApplicationHelper
|
||||
include Diaspora::Parser
|
||||
|
||||
|
||||
|
||||
describe Diaspora::Parser do
|
||||
before do
|
||||
@user = Factory.create(:user, :email => "bob@aol.com")
|
||||
|
|
@ -123,7 +125,8 @@ describe Diaspora::Parser do
|
|||
Person.all.count.should be 2
|
||||
|
||||
Person.first(:_id => original_person_id).serialized_key.include?("PUBLIC").should be true
|
||||
Person.where(:url => request.callback_url).first.id.should == original_person_id
|
||||
url = "http://" + request.callback_url.split("/")[2] + "/"
|
||||
Person.where(:url => url).first.id.should == original_person_id
|
||||
end
|
||||
|
||||
it "should not create a new person if the person is already here" do
|
||||
|
|
@ -140,19 +143,23 @@ describe Diaspora::Parser do
|
|||
|
||||
@user2.reload
|
||||
@user2.person.reload
|
||||
puts @user2.inspect
|
||||
puts @user2.person.inspect
|
||||
@user2.person.serialized_key.include?("PRIVATE").should be true
|
||||
|
||||
Person.where(:url => request.callback_url).first.id.should == original_person_id
|
||||
url = "http://" + request.callback_url.split("/")[2] + "/"
|
||||
Person.where(:url => url).first.id.should == original_person_id
|
||||
end
|
||||
|
||||
it "should activate the Person if I initiated a request to that url" do
|
||||
request = Request.instantiate(:to => @person.url, :from => @user).save
|
||||
request = Request.instantiate(:to => @person.receive_url, :from => @user)
|
||||
request.save
|
||||
@user.pending_requests << request
|
||||
@user.save
|
||||
|
||||
|
||||
request_remote = Request.new
|
||||
request_remote.destination_url = @user.url
|
||||
request_remote.callback_url = @user.url
|
||||
request_remote.id = request.id
|
||||
request_remote.destination_url = @user.receive_url
|
||||
request_remote.callback_url = @user.receive_url
|
||||
request_remote.person = @person
|
||||
request_remote.exported_key = @person.export_key
|
||||
|
||||
|
|
@ -163,6 +170,7 @@ describe Diaspora::Parser do
|
|||
store_objects_from_xml(xml, @user)
|
||||
new_person = Person.first(:url => @person.url)
|
||||
new_person.nil?.should be false
|
||||
|
||||
@user.reload
|
||||
@user.friends.include?(new_person).should be true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ describe Comment do
|
|||
end
|
||||
|
||||
it 'should send a user comment on his own post to lots of people' do
|
||||
allowed_urls = @user_status.people_with_permissions.map{|x| x = x.url + "receive/"}
|
||||
allowed_urls = @user_status.people_with_permissions.map{|x| x = x.receive_url}
|
||||
message_queue.should_receive(:add_post_request).with(allowed_urls, anything)
|
||||
@user.comment "yo", :on => @user_status
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ describe Request do
|
|||
user = Factory.create(:user)
|
||||
remote_person = Factory.build(:person, :email => "robert@grimm.com", :url => "http://king.com/")
|
||||
|
||||
Request.instantiate(:from => user.person, :to => remote_person.url).save
|
||||
Request.instantiate(:from => user.person, :to => remote_person.url).save
|
||||
Request.instantiate(:from => user.person, :to => remote_person.url).save
|
||||
Request.instantiate(:from => remote_person, :to => user.url).save
|
||||
Request.instantiate(:from => user.person, :to => remote_person.receive_url).save
|
||||
Request.instantiate(:from => user.person, :to => remote_person.receive_url).save
|
||||
Request.instantiate(:from => user.person, :to => remote_person.receive_url).save
|
||||
Request.instantiate(:from => remote_person, :to => user.receive_url).save
|
||||
|
||||
Request.for_user(user).all.count.should == 1
|
||||
end
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ describe User do
|
|||
describe 'friend requesting' do
|
||||
it "should be able to accept a pending friend request" do
|
||||
friend = Factory.create(:person)
|
||||
r = Request.instantiate(:to => @user.url, :from => friend)
|
||||
r = Request.instantiate(:to => @user.receive_url, :from => friend)
|
||||
r.save
|
||||
Person.all.count.should == 2
|
||||
Request.for_user(@user).all.count.should == 1
|
||||
|
|
@ -39,7 +39,7 @@ describe User do
|
|||
|
||||
it 'should be able to ignore a pending friend request' do
|
||||
friend = Factory.create(:person)
|
||||
r = Request.instantiate(:to => @user.url, :from => friend)
|
||||
r = Request.instantiate(:to => @user.receive_url, :from => friend)
|
||||
r.save
|
||||
|
||||
Person.count.should == 2
|
||||
|
|
@ -58,7 +58,7 @@ describe User do
|
|||
@user.save
|
||||
|
||||
|
||||
@user.send_friend_request_to( friend.url ).should be nil
|
||||
@user.send_friend_request_to( friend.receive_url ).should be nil
|
||||
end
|
||||
|
||||
it 'should be able to give me the terse url for webfinger' do
|
||||
|
|
@ -73,13 +73,13 @@ describe User do
|
|||
@user.pending_requests.empty?.should be true
|
||||
@user.friends.empty?.should be true
|
||||
|
||||
request = Request.instantiate(:to => @user.url, :from => person_one)
|
||||
request = Request.instantiate(:to => @user.receive_url, :from => person_one)
|
||||
person_one.destroy
|
||||
@user.receive_friend_request request
|
||||
@user.pending_requests.size.should be 1
|
||||
@user.friends.size.should be 0
|
||||
|
||||
request_two = Request.instantiate(:to => @user.url, :from => person_two)
|
||||
request_two = Request.instantiate(:to => @user.receive_url, :from => person_two)
|
||||
person_two.destroy
|
||||
@user.receive_friend_request request_two
|
||||
@user.pending_requests.size.should be 2
|
||||
|
|
|
|||
Loading…
Reference in a new issue