MS^2 Comments serialize and deserialize properly

This commit is contained in:
maxwell 2010-06-25 22:49:53 -07:00
parent e4e2d52bcb
commit 6467f943da
3 changed files with 6 additions and 3 deletions

View file

@ -42,7 +42,8 @@ module ApplicationHelper
objects = parse_objects_from_xml(xml)
objects.each do |p|
p.save if p.respond_to?(:person) && p.person
p.save if p.respond_to?(:person) && !(p.person.nil?) #WTF
#p.save if p.respond_to?(:person) && !(p.person == nil) #WTF
end
end

View file

@ -30,3 +30,5 @@ end
Factory.define :post do |p|
end
Factory.define(:comment) {}

View file

@ -103,16 +103,16 @@ describe "parser in application helper" do
it 'should be able to correctly handle comments' do
friend = Factory.create(:friend)
post = Factory.create(:status_message)
comment = Factory.build(:comment, :post => post, :person => friend, :text => "Freedom!")
xml = "<XML><head><sender><email>#{Friend.first.email}</email></sender></head>
<posts>
<post><comment>\n <text>Freedom!</text>\n <person>#{friend.id}</person>\n <post_id>#{post.id}}</post_id>\n</comment></post>
<post>#{comment.to_xml}</post>
</posts></XML>"
objects = parse_objects_from_xml(xml)
comment = objects.first
comment.text.should == "Freedom!"
comment.person.should == friend
comment.post.should == post
end
end