Failing spec for the second retraction for a reshared post, reshares need to refer to guids
This commit is contained in:
parent
ad5dba052c
commit
4b1d5b772d
3 changed files with 34 additions and 3 deletions
|
|
@ -43,8 +43,7 @@ class Reshare < Post
|
|||
local_post = Post.where(:guid => @root_guid).select('id').first
|
||||
|
||||
unless local_post && self.root_id = local_post.id
|
||||
response = Faraday.get(root_author.url + "/p/#{@root_guid}.xml")
|
||||
received_post = Diaspora::Parser.from_xml(response.body)
|
||||
received_post = self.class.fetch_post(root_author, @root_guid)
|
||||
|
||||
unless post = received_post.class.where(:guid => received_post.guid).first
|
||||
post = received_post
|
||||
|
|
@ -61,6 +60,15 @@ class Reshare < Post
|
|||
end
|
||||
end
|
||||
|
||||
# Fetch a remote public post, used for receiving reshares of unknown posts
|
||||
# @param [Person] author the remote post's author
|
||||
# @param [String] guid the remote post's guid
|
||||
# @return [Post] an unsaved remote post
|
||||
def self.fetch_post author, guid
|
||||
response = Faraday.get(root_author.url + "/p/#{@root_guid}.xml")
|
||||
Diaspora::Parser.from_xml(response.body)
|
||||
end
|
||||
|
||||
def root_must_be_public
|
||||
if self.root && !self.root.public
|
||||
errors[:base] << "you must reshare public posts"
|
||||
|
|
|
|||
|
|
@ -19,5 +19,29 @@ describe SignedRetraction do
|
|||
|
||||
retraction.perform(@resharer)
|
||||
end
|
||||
it 'relays the retraction onward even if the post does not exist' do
|
||||
remote_post = Factory(:status_message, :public => true)
|
||||
bob.post(:reshare, :root_id => remote_post.id)
|
||||
alice.post(:reshare, :root_id => remote_post.id)
|
||||
|
||||
remote_retraction = SignedRetraction.new.tap{|r|
|
||||
r.target_type = remote_post.type
|
||||
r.target_guid = remote_post.guid
|
||||
r.sender = remote_post.author
|
||||
r.stub!(:target_author_signature_valid?).and_return(true)
|
||||
}
|
||||
|
||||
remote_retraction.dup.perform(bob)
|
||||
Post.exists?(:id => remote_post.id).should be_false
|
||||
|
||||
dis = mock
|
||||
Postzord::Dispatch.should_receive(:new){ |sender, retraction|
|
||||
sender.should == alice
|
||||
retraction.sender.should == alice.person
|
||||
dis
|
||||
}
|
||||
dis.should_receive(:post)
|
||||
remote_retraction.perform(alice)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -72,6 +72,5 @@ unless Server.all.empty?
|
|||
Post.exists?(:guid => @original_post.guid).should be_false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue