diff --git a/app/models/user.rb b/app/models/user.rb index ceaf9f56424ebe5186d56d3d3463c261845f80f1..072fd006ef1699f85b5fdbef9b2e76d2157fbef4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -166,7 +166,7 @@ class User object = Diaspora::Parser.from_xml(xml) Rails.logger.debug("Receiving object:\n#{object.inspect}") Rails.logger.debug("From: #{object.person.inspect}") if object.person - raise "In receive for #{self.real_name}, signature was not valid on: #{object.inspect}" unless object.signature_valid? + if object.is_a? Retraction if object.type == 'Person' && object.signature_valid? @@ -196,6 +196,7 @@ class User elsif object.is_a?(Comment) object.person = Diaspora::Parser.parse_or_find_person_from_xml( xml ).save if object.person.nil? + Rails.logger.debug("The person parsed from comment xml is #{object.person.inspect}") unless object.person.nil? object.person.save Rails.logger.debug("From: #{object.person.inspect}") if object.person raise "In receive for #{self.real_name}, signature was not valid on: #{object.inspect}" unless object.post.person == self.person || object.verify_post_creator_signature diff --git a/spec/models/user/receive_spec.rb b/spec/models/user/receive_spec.rb index 9807893184c820200947853ae0310ca5e7fd79d3..9480dd60c8dad980ff70583b089e8b5c9cc8869d 100644 --- a/spec/models/user/receive_spec.rb +++ b/spec/models/user/receive_spec.rb @@ -133,4 +133,37 @@ describe User do Post.count.should be 1 end end + + describe 'comments' do + it 'should correctly marshal to the downstream user' do + + + @user3 = Factory.create(:user) + @group3 = @user3.group(:name => 'heroes') + + puts @user.inspect + puts @group.inspect + friend_users(@user, @group, @user3, @group3) + + + status_message = @user.post :status_message, :message => 'store this!', :to => @group.id + + @user2.receive status_message.to_diaspora_xml + @user3.receive status_message.to_diaspora_xml + + comment = @user2.comment('tada',:on => status_message) + @user.receive comment.to_diaspora_xml + @user.reload + + @user.raw_visible_posts.first.comments.first.nil?.should be false + upstream_comment = @user.raw_visible_posts.first.comments.first + + @user2.person.delete + @user3.receive upstream_comment.to_diaspora_xml + @user3.reload + + @user3.raw_visible_posts.first.comments.first.nil?.should be false + + end + end end