diff --git a/app/models/comment.rb b/app/models/comment.rb index 747602ba76fe7f8bfa678829437baa83722c2b10..21faf3994f8d751d54fd04f801ab14f76e6c9ac6 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -75,6 +75,10 @@ class Comment < ActiveRecord::Base self.post = parent end + def text= text + self[:text] = text.to_s.strip #to_s if for nil, for whatever reason + end + class Generator < Federated::Generator def self.federated_class Comment diff --git a/spec/integration/receiving_spec.rb b/spec/integration/receiving_spec.rb index 3a3ac786ccc4722c0287e6381ece114eda58fc63..6b15ec72f8f91c3ba29d16b5dfa956faef2dee76 100644 --- a/spec/integration/receiving_spec.rb +++ b/spec/integration/receiving_spec.rb @@ -183,12 +183,28 @@ describe 'a user receives a post' do receive_with_zord(eve, alice.person, xml) comment = eve.comment!(@post, 'tada') + # After Eve creates her comment, it gets sent to Alice, who signs it with her private key + # before relaying it out to the contacts on the top-level post comment.parent_author_signature = comment.sign_with_key(alice.encryption_key) @xml = comment.to_diaspora_xml comment.delete + + comment_with_whitespace = alice.comment!(@post, ' I cannot lift my thumb from the spacebar ') + @xml_with_whitespace = comment_with_whitespace.to_diaspora_xml + @guid_with_whitespace = comment_with_whitespace.guid + comment_with_whitespace.delete end end + it 'should receive a relayed comment with leading whitespace' do + eve.reload.visible_shareables(Post).size.should == 1 + post_in_db = StatusMessage.find(@post.id) + post_in_db.comments.should == [] + receive_with_zord(eve, alice.person, @xml_with_whitespace) + + post_in_db.comments(true).first.guid.should == @guid_with_whitespace + end + it 'should correctly attach the user already on the pod' do bob.reload.visible_shareables(Post).size.should == 1 post_in_db = StatusMessage.find(@post.id)