DG IZ; person request now appends url to pass validations when saved from inbound XML

This commit is contained in:
danielvincent 2010-07-07 20:24:50 -07:00
parent 69e1d94bfe
commit b496ee567a
2 changed files with 14 additions and 6 deletions

View file

@ -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

View file

@ -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