MS^2 Comments serialize and deserialize properly
This commit is contained in:
parent
e4e2d52bcb
commit
6467f943da
3 changed files with 6 additions and 3 deletions
|
|
@ -42,7 +42,8 @@ module ApplicationHelper
|
||||||
objects = parse_objects_from_xml(xml)
|
objects = parse_objects_from_xml(xml)
|
||||||
|
|
||||||
objects.each do |p|
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,3 +30,5 @@ end
|
||||||
|
|
||||||
Factory.define :post do |p|
|
Factory.define :post do |p|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Factory.define(:comment) {}
|
||||||
|
|
@ -103,16 +103,16 @@ describe "parser in application helper" do
|
||||||
it 'should be able to correctly handle comments' do
|
it 'should be able to correctly handle comments' do
|
||||||
friend = Factory.create(:friend)
|
friend = Factory.create(:friend)
|
||||||
post = Factory.create(:status_message)
|
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>
|
xml = "<XML><head><sender><email>#{Friend.first.email}</email></sender></head>
|
||||||
<posts>
|
<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>"
|
</posts></XML>"
|
||||||
objects = parse_objects_from_xml(xml)
|
objects = parse_objects_from_xml(xml)
|
||||||
comment = objects.first
|
comment = objects.first
|
||||||
comment.text.should == "Freedom!"
|
comment.text.should == "Freedom!"
|
||||||
comment.person.should == friend
|
comment.person.should == friend
|
||||||
comment.post.should == post
|
comment.post.should == post
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue