RS, DG; Removed <posts> from xml

This commit is contained in:
Raphael 2010-08-11 14:26:39 -07:00
parent 5abd604dad
commit 11758beaf3
4 changed files with 4 additions and 30 deletions

View file

@ -8,7 +8,7 @@ module Diaspora
def parse_body_contents_from_xml(xml)
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
doc.xpath("/XML/posts/post")
doc.xpath("/XML/post")
end
def parse_owner_id_from_xml(doc)

View file

@ -36,9 +36,7 @@ module Diaspora
def to_diaspora_xml
xml = "<XML>"
xml += "<posts>"
xml += "<post>#{self.to_xml.to_s}</post>"
xml += "</posts>"
xml += "</XML>"
end

View file

@ -23,31 +23,16 @@ describe Diaspora::Parser do
it "should reject xml with no sender" do
xml = "<XML>
<head>
</head><posts>
</head>
<post><status_message>\n <message>Here is another message</message>\n <owner>a@a.com</owner>\n <snippet>a@a.com</snippet>\n <source>a@a.com</source>\n</status_message></post>
<post><person></person></post>
<post><status_message>\n <message>HEY DUDE</message>\n <owner>a@a.com</owner>\n <snippet>a@a.com</snippet>\n <source>a@a.com</source>\n</status_message></post>
</posts></XML>"
</XML>"
store_objects_from_xml(xml, @user)
Post.count.should == 0
end
it "should reject xml with a sender not in the database" do
xml = "<XML>
<head>
<sender>
<email>foo@example.com</email>
</sender>
</head><posts>
<post><status_message>\n <message>Here is another message</message>\n <owner>a@a.com</owner>\n <snippet>a@a.com</snippet>\n <source>a@a.com</source>\n</status_message></post>
<post><person></person></post>
<post><status_message>\n <message>HEY DUDE</message>\n <owner>a@a.com</owner>\n <snippet>a@a.com</snippet>\n <source>a@a.com</source>\n</status_message></post>
</posts></XML>"
store_objects_from_xml(xml, @user)
Post.count.should == 0
end
it 'should discard types which are not of type post' do
xml = "<XML>
<head>
@ -71,8 +56,6 @@ describe Diaspora::Parser do
it 'should be able to parse the body\'s contents' do
body = parse_body_contents_from_xml(@xml).to_s
body.should_not include "<posts>"
body.should_not include "</posts>"
body.should include "<post>"
body.should include "</post>"
end
@ -87,10 +70,7 @@ describe Diaspora::Parser do
person = Factory.create(:person, :email => "test@testing.com")
post = Factory.create(:status_message, :person => @user.person)
comment = Factory.build(:comment, :post => post, :person => person, :text => "Freedom!")
xml = "<XML>
<posts>
<post>#{comment.to_xml}</post>
</posts></XML>"
xml = comment.to_diaspora_xml
objects = parse_objects_from_xml(xml)
comment = objects.first

View file

@ -22,10 +22,6 @@ describe Diaspora do
@post.respond_to?(:people_with_permissions).should be true
end
it "should convert an object to a proper diaspora entry" do
@post.to_diaspora_xml.should == "<XML><posts><post>#{@post.to_xml.to_s}</post></posts></XML>"
end
it "should retrieve all valid person endpoints" do
@user.friends << Factory.create(:person, :url => "http://www.bob.com/")
@user.friends << Factory.create(:person, :url => "http://www.alice.com/")