diff --git a/lib/common.rb b/lib/common.rb index 537c50c0e..b7fe7749b 100644 --- a/lib/common.rb +++ b/lib/common.rb @@ -34,11 +34,14 @@ module Diaspora if p.is_a? Retraction p.perform elsif p.is_a? PersonRequest - if PersonRequest.where(:url => p.url).first - p.active = true + if PersonRequest.where(:_id => p._id).first + p.person.active = true end + + p.url = p.person.url p.save p.person.save + #This line checks if the sender was in the database, among other things? elsif p.respond_to?(:person) && !(p.person.nil?) && !(p.person.is_a? User) #WTF p.save diff --git a/spec/lib/parser_spec.rb b/spec/lib/parser_spec.rb index 95ed70894..fe93b33bb 100644 --- a/spec/lib/parser_spec.rb +++ b/spec/lib/parser_spec.rb @@ -114,22 +114,27 @@ describe "parser in application helper" do request = PersonRequest.new(:url => "http://www.googles.com/") request.person = @person - xml = Post.build_xml_for [request] + xml = PersonRequest.build_xml_for [request] @person.destroy @user.destroy Person.count.should be 0 store_objects_from_xml(xml) Person.count.should be 1 + puts Person.first.inspect end it "should activate the Person if I initiated a request to that url" do request = PersonRequest.create(:url => @person.url, :person => @user) - request_remote = PersonRequest.new(:url => "http://www.yahoo.com/") + request_remote = PersonRequest.new(:_id => request.id, :url => "http://www.yahoo.com/") request_remote.person = @person.clone - xml = Post.build_xml_for [request_remote] - + xml = PersonRequest.build_xml_for [request_remote] + + @person.destroy + @user.destroy + request_remote.destroy + store_objects_from_xml(xml) Person.where(:url => @person.url).first.active.should be true end