RS, DG; build_xml_for has been eliminated.
This commit is contained in:
parent
e94faf89bb
commit
5abd604dad
8 changed files with 26 additions and 35 deletions
|
|
@ -23,9 +23,4 @@ class Profile
|
||||||
def person
|
def person
|
||||||
Person.first(:id => self.person_id)
|
Person.first(:id => self.person_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_diaspora_xml
|
|
||||||
"<post>"+ self.to_xml.to_s + "</post>"
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ module Diaspora
|
||||||
rescue NameError => e
|
rescue NameError => e
|
||||||
if e.message.include? 'wrong constant name'
|
if e.message.include? 'wrong constant name'
|
||||||
Rails.logger.info "Not a real type: #{object.to_s}"
|
Rails.logger.info "Not a real type: #{object.to_s}"
|
||||||
|
raise e
|
||||||
else
|
else
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ module Diaspora
|
||||||
def push_to(recipients)
|
def push_to(recipients)
|
||||||
unless recipients.empty?
|
unless recipients.empty?
|
||||||
recipients.map!{|x| x = x.receive_url }
|
recipients.map!{|x| x = x.receive_url }
|
||||||
xml = build_xml_for
|
xml = to_diaspora_xml
|
||||||
Rails.logger.debug("Adding xml for #{self} to message queue to #{recipients}")
|
Rails.logger.debug("Adding xml for #{self} to message queue to #{recipients}")
|
||||||
@@queue.add_post_request( recipients, xml )
|
@@queue.add_post_request( recipients, xml )
|
||||||
end
|
end
|
||||||
|
|
@ -28,14 +28,18 @@ module Diaspora
|
||||||
|
|
||||||
def push_to_url(url)
|
def push_to_url(url)
|
||||||
hook_url = url
|
hook_url = url
|
||||||
xml = build_xml_for
|
xml = to_diaspora_xml
|
||||||
Rails.logger.debug("Adding xml for #{self} to message queue to #{url}")
|
Rails.logger.debug("Adding xml for #{self} to message queue to #{url}")
|
||||||
@@queue.add_post_request( hook_url, xml )
|
@@queue.add_post_request( hook_url, xml )
|
||||||
@@queue.process
|
@@queue.process
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_diaspora_xml
|
def to_diaspora_xml
|
||||||
"<post>#{self.to_xml.to_s}</post>"
|
xml = "<XML>"
|
||||||
|
xml += "<posts>"
|
||||||
|
xml += "<post>#{self.to_xml.to_s}</post>"
|
||||||
|
xml += "</posts>"
|
||||||
|
xml += "</XML>"
|
||||||
end
|
end
|
||||||
|
|
||||||
def people_with_permissions
|
def people_with_permissions
|
||||||
|
|
@ -48,15 +52,6 @@ module Diaspora
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_xml_for
|
|
||||||
xml = "<XML>"
|
|
||||||
xml += "\n <posts>"
|
|
||||||
xml << to_diaspora_xml
|
|
||||||
xml += "</posts>"
|
|
||||||
xml += "</XML>"
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ describe PublicsController do
|
||||||
person = Factory.create(:person)
|
person = Factory.create(:person)
|
||||||
message = StatusMessage.new(:message => 'foo', :person => person)
|
message = StatusMessage.new(:message => 'foo', :person => person)
|
||||||
StatusMessage.all.count.should be 0
|
StatusMessage.all.count.should be 0
|
||||||
post :receive, :id => @user.person.id, :xml => message.build_xml_for(message)
|
post :receive, :id => @user.person.id, :xml => message.to_diaspora_xml(message)
|
||||||
StatusMessage.all.count.should be 1
|
StatusMessage.all.count.should be 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -37,7 +37,7 @@ describe PublicsController do
|
||||||
|
|
||||||
req = @user2.send_friend_request_to(@user.person.url)
|
req = @user2.send_friend_request_to(@user.person.url)
|
||||||
#req = Request.instantiate(:from => @user2.person, :to => @user.person.url)
|
#req = Request.instantiate(:from => @user2.person, :to => @user.person.url)
|
||||||
@xml = req.build_xml_for
|
@xml = req.to_diaspora_xml
|
||||||
|
|
||||||
req.delete
|
req.delete
|
||||||
@user2.reload
|
@user2.reload
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ describe Diaspora::Parser do
|
||||||
it "should not store posts from me" do
|
it "should not store posts from me" do
|
||||||
10.times {
|
10.times {
|
||||||
message = Factory.build(:status_message, :person => @user)
|
message = Factory.build(:status_message, :person => @user)
|
||||||
xml = message.build_xml_for
|
xml = message.to_diaspora_xml
|
||||||
store_objects_from_xml(xml, @user)
|
store_objects_from_xml(xml, @user)
|
||||||
}
|
}
|
||||||
StatusMessage.count.should == 0
|
StatusMessage.count.should == 0
|
||||||
|
|
@ -66,7 +66,7 @@ describe Diaspora::Parser do
|
||||||
|
|
||||||
describe "parsing compliant XML object" do
|
describe "parsing compliant XML object" do
|
||||||
before do
|
before do
|
||||||
@xml = Factory.build(:status_message).build_xml_for
|
@xml = Factory.build(:status_message).to_diaspora_xml
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be able to parse the body\'s contents' do
|
it 'should be able to parse the body\'s contents' do
|
||||||
|
|
@ -103,7 +103,7 @@ describe Diaspora::Parser do
|
||||||
person = Factory.create(:person)
|
person = Factory.create(:person)
|
||||||
message = Factory.create(:status_message, :person => person)
|
message = Factory.create(:status_message, :person => person)
|
||||||
retraction = Retraction.for(message)
|
retraction = Retraction.for(message)
|
||||||
request = retraction.build_xml_for
|
request = retraction.to_diaspora_xml
|
||||||
|
|
||||||
StatusMessage.count.should == 1
|
StatusMessage.count.should == 1
|
||||||
store_objects_from_xml( request, @user )
|
store_objects_from_xml( request, @user )
|
||||||
|
|
@ -114,7 +114,7 @@ describe Diaspora::Parser do
|
||||||
request = Request.instantiate(:to =>"http://www.google.com/", :from => @person)
|
request = Request.instantiate(:to =>"http://www.google.com/", :from => @person)
|
||||||
|
|
||||||
original_person_id = @person.id
|
original_person_id = @person.id
|
||||||
xml = request.build_xml_for
|
xml = request.to_diaspora_xml
|
||||||
|
|
||||||
@person.destroy
|
@person.destroy
|
||||||
Person.all.count.should be 1
|
Person.all.count.should be 1
|
||||||
|
|
@ -131,7 +131,7 @@ describe Diaspora::Parser do
|
||||||
request = Request.instantiate(:to =>"http://www.google.com/", :from => @user2.person)
|
request = Request.instantiate(:to =>"http://www.google.com/", :from => @user2.person)
|
||||||
|
|
||||||
original_person_id = @user2.person.id
|
original_person_id = @user2.person.id
|
||||||
xml = request.build_xml_for
|
xml = request.to_diaspora_xml
|
||||||
|
|
||||||
|
|
||||||
Person.all.count.should be 3
|
Person.all.count.should be 3
|
||||||
|
|
@ -160,7 +160,7 @@ describe Diaspora::Parser do
|
||||||
request_remote.person = @person
|
request_remote.person = @person
|
||||||
request_remote.exported_key = @person.export_key
|
request_remote.exported_key = @person.export_key
|
||||||
|
|
||||||
xml = request_remote.build_xml_for
|
xml = request_remote.to_diaspora_xml
|
||||||
|
|
||||||
@person.destroy
|
@person.destroy
|
||||||
request_remote.destroy
|
request_remote.destroy
|
||||||
|
|
@ -175,7 +175,7 @@ describe Diaspora::Parser do
|
||||||
|
|
||||||
it 'should process retraction for a person' do
|
it 'should process retraction for a person' do
|
||||||
retraction = Retraction.for(@user)
|
retraction = Retraction.for(@user)
|
||||||
request = retraction.build_xml_for
|
request = retraction.to_diaspora_xml
|
||||||
|
|
||||||
Person.count.should == 2
|
Person.count.should == 2
|
||||||
store_objects_from_xml( request , @user)
|
store_objects_from_xml( request , @user)
|
||||||
|
|
@ -194,7 +194,7 @@ describe Diaspora::Parser do
|
||||||
old_profile.first_name.should == 'bob'
|
old_profile.first_name.should == 'bob'
|
||||||
|
|
||||||
#Build xml for profile, clear profile
|
#Build xml for profile, clear profile
|
||||||
xml = person.profile.build_xml_for
|
xml = person.profile.to_diaspora_xml
|
||||||
reloaded_person = Person.first(:id => id)
|
reloaded_person = Person.first(:id => id)
|
||||||
reloaded_person.profile = nil
|
reloaded_person.profile = nil
|
||||||
reloaded_person.save(:validate => false)
|
reloaded_person.save(:validate => false)
|
||||||
|
|
@ -209,7 +209,7 @@ describe Diaspora::Parser do
|
||||||
#Check that marshaled profile is the same as old profile
|
#Check that marshaled profile is the same as old profile
|
||||||
person = Person.first(:id => person.id)
|
person = Person.first(:id => person.id)
|
||||||
person.profile.should_not be nil
|
person.profile.should_not be nil
|
||||||
person.profile.first_name.should == old_profile.first_name
|
person.profile.first_name.should == old_profile.first_name
|
||||||
person.profile.last_name.should == old_profile.last_name
|
person.profile.last_name.should == old_profile.last_name
|
||||||
person.profile.image_url.should == old_profile.image_url
|
person.profile.image_url.should == old_profile.image_url
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ describe Diaspora do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should convert an object to a proper diaspora entry" do
|
it "should convert an object to a proper diaspora entry" do
|
||||||
@post.to_diaspora_xml.should == "<post>#{@post.to_xml.to_s}</post>"
|
@post.to_diaspora_xml.should == "<XML><posts><post>#{@post.to_xml.to_s}</post></posts></XML>"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should retrieve all valid person endpoints" do
|
it "should retrieve all valid person endpoints" do
|
||||||
|
|
|
||||||
|
|
@ -78,9 +78,9 @@ describe User do
|
||||||
@request_three = Request.instantiate(:to => @user2.receive_url, :from => @user.person)
|
@request_three = Request.instantiate(:to => @user2.receive_url, :from => @user.person)
|
||||||
|
|
||||||
|
|
||||||
@req_xml = @request.build_xml_for
|
@req_xml = @request.to_diaspora_xml
|
||||||
@req_two_xml = @request_two.build_xml_for
|
@req_two_xml = @request_two.to_diaspora_xml
|
||||||
@req_three_xml = @request_three.build_xml_for
|
@req_three_xml = @request_three.to_diaspora_xml
|
||||||
|
|
||||||
|
|
||||||
@request.destroy
|
@request.destroy
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ describe 'user encryption' do
|
||||||
it 'should send over a public key' do
|
it 'should send over a public key' do
|
||||||
message_queue.stub!(:add_post_request)
|
message_queue.stub!(:add_post_request)
|
||||||
request = @user.send_friend_request_to("http://example.com/")
|
request = @user.send_friend_request_to("http://example.com/")
|
||||||
request.build_xml_for.include?( @user.export_key).should be true
|
request.to_diaspora_xml.include?( @user.export_key).should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should receive and marshal a public key from a request' do
|
it 'should receive and marshal a public key from a request' do
|
||||||
|
|
@ -51,7 +51,7 @@ describe 'user encryption' do
|
||||||
|
|
||||||
request = Request.instantiate(:to =>"http://www.google.com/", :from => person)
|
request = Request.instantiate(:to =>"http://www.google.com/", :from => person)
|
||||||
|
|
||||||
xml = request.build_xml_for
|
xml = request.to_diaspora_xml
|
||||||
person.destroy
|
person.destroy
|
||||||
personcount = Person.all.count
|
personcount = Person.all.count
|
||||||
store_objects_from_xml(xml, @user)
|
store_objects_from_xml(xml, @user)
|
||||||
|
|
@ -110,7 +110,7 @@ describe 'user encryption' do
|
||||||
message = Factory.build(:status_message, :person => @person)
|
message = Factory.build(:status_message, :person => @person)
|
||||||
message.creator_signature = "totally valid"
|
message.creator_signature = "totally valid"
|
||||||
message.save
|
message.save
|
||||||
xml = message.build_xml_for
|
xml = message.to_diaspora_xml
|
||||||
message.destroy
|
message.destroy
|
||||||
Post.count.should be 0
|
Post.count.should be 0
|
||||||
store_objects_from_xml(xml, @user)
|
store_objects_from_xml(xml, @user)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue