add rspec test and make fix more rails-y
This commit is contained in:
parent
ed51f34ebb
commit
44e43158cc
2 changed files with 21 additions and 1 deletions
|
|
@ -75,13 +75,17 @@ class Comment < ActiveRecord::Base
|
||||||
self.post = parent
|
self.post = parent
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def text= text
|
||||||
|
self[:text] = text.to_s.strip #to_s if for nil, for whatever reason
|
||||||
|
end
|
||||||
|
|
||||||
class Generator < Federated::Generator
|
class Generator < Federated::Generator
|
||||||
def self.federated_class
|
def self.federated_class
|
||||||
Comment
|
Comment
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(person, target, text)
|
def initialize(person, target, text)
|
||||||
@text = text.strip # remove leading and trailing whitespace now, otherwise it can cause signature issues
|
@text = text
|
||||||
super(person, target)
|
super(person, target)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -183,12 +183,28 @@ describe 'a user receives a post' do
|
||||||
receive_with_zord(eve, alice.person, xml)
|
receive_with_zord(eve, alice.person, xml)
|
||||||
|
|
||||||
comment = eve.comment!(@post, 'tada')
|
comment = eve.comment!(@post, 'tada')
|
||||||
|
# Note: eve.comment! has already initialized comment.parent_author_signature. Writing to it again
|
||||||
|
# here causes the test to be different than the way the system actually runs
|
||||||
comment.parent_author_signature = comment.sign_with_key(alice.encryption_key)
|
comment.parent_author_signature = comment.sign_with_key(alice.encryption_key)
|
||||||
@xml = comment.to_diaspora_xml
|
@xml = comment.to_diaspora_xml
|
||||||
comment.delete
|
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
|
||||||
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
|
it 'should correctly attach the user already on the pod' do
|
||||||
bob.reload.visible_shareables(Post).size.should == 1
|
bob.reload.visible_shareables(Post).size.should == 1
|
||||||
post_in_db = StatusMessage.find(@post.id)
|
post_in_db = StatusMessage.find(@post.id)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue