First reshare retraction spec is green

This commit is contained in:
Raphael Sofaer 2011-07-22 13:12:12 -07:00
parent 17774d8b3b
commit ad5dba052c
4 changed files with 34 additions and 32 deletions

View file

@ -22,7 +22,7 @@ class SignedRetraction
accessors = self.class.roxml_attrs.collect do |definition|
definition.accessor
end
accessors - ['target_author_signature']
accessors - ['target_author_signature', 'sender_handle']
end
def sender_handle= new_sender_handle
@ -34,7 +34,7 @@ class SignedRetraction
end
def diaspora_handle
self.target.diaspora_handle
self.sender_handle
end
def subscribers(user)
@ -64,9 +64,10 @@ class SignedRetraction
def perform receiving_user
Rails.logger.debug "Performing retraction for #{target_guid}"
puts "Performing retraction for #{target_guid}"
if reshare = Reshare.where(:author_id => receiving_user.person.id, :root_id => target.id).first
Postzord::Dispatch.new(receiving_user, self).post
onward_retraction = self.dup
onward_retraction.sender = receiving_user.person
Postzord::Dispatch.new(receiving_user, onward_retraction).post
end
self.target.unsocket_from_user receiving_user if target.respond_to? :unsocket_from_user
self.target.destroy
@ -81,7 +82,7 @@ class SignedRetraction
#this is a retraction from the upstream owner
self.perform(recipient)
else
Rails.logger.info("event=receive status=abort reason='object signature not valid' recipient=#{recipient.diaspora_handle} sender=#{self.parent.author.diaspora_handle} payload_type=#{self.class} parent_id=#{self.parent.id}")
Rails.logger.info("event=receive status=abort reason='object signature not valid' recipient=#{recipient.diaspora_handle} sender=#{self.sender_handle} payload_type=#{self.class}")
return
end
self

View file

@ -0,0 +1,23 @@
require 'spec_helper'
describe SignedRetraction do
before do
@post = Factory(:status_message, :author => bob.person, :public => true)
@resharer = Factory(:user)
@post.reshares << Factory.create(:reshare,:root_id => @post.id, :author => @resharer.person)
@post.save!
end
describe '#perform' do
it "dispatches the retraction onward to recipients of the recipient's reshare" do
retraction = SignedRetraction.build(bob, @post)
onward_retraction = retraction.dup
retraction.should_receive(:dup).and_return(onward_retraction)
dis = mock
Postzord::Dispatch.should_receive(:new).with(@resharer, onward_retraction).and_return(dis)
dis.should_receive(:post)
retraction.perform(@resharer)
end
end
end

View file

@ -790,27 +790,5 @@ describe User do
pending
end
end
context "signed retractions" do
before do
@post.reshares << Factory.create(:reshare,:root_id => @post.id, :author => Factory(:user).person)
@post.save!
end
it 'relays the signed retraction onwards to recipients of reshares' do
r_ret = SignedRetraction.build(bob, @post)
SignedRetraction.should_receive(:build).and_return(r_ret)
dis = mock
dis_2 = mock
dis.should_receive(:post).and_return{ r_ret.perform(@post.reshares.first.author.owner)}
#dis_2.should_receive(:post)
Postzord::Dispatch.should_receive(:new).with(bob, r_ret, anything()).and_return(dis, dis_2)
fantasy_resque do
bob.retract(@post)
end
end
end
end
end

View file

@ -5,14 +5,14 @@ unless Server.all.empty?
describe Server do
before(:all) do
WebMock::Config.instance.allow_localhost = true
Server.all.each{|s| s.kill if s.running?}
Server.all.each{|s| s.run}
#Server.all.each{|s| s.kill if s.running?}
#Server.all.each{|s| s.run}
end
after(:all) do
Server.all.each{|s| s.kill if s.running?}
sleep(1)
Server.all.each{|s| puts "Server at port #{s.port} still running." if s.running?}
#Server.all.each{|s| s.kill if s.running?}
#sleep(1)
#Server.all.each{|s| puts "Server at port #{s.port} still running." if s.running?}
WebMock::Config.instance.allow_localhost = false
end