diff --git a/app/models/signed_retraction.rb b/app/models/signed_retraction.rb index 75a4e5477..a499c7d87 100644 --- a/app/models/signed_retraction.rb +++ b/app/models/signed_retraction.rb @@ -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 diff --git a/spec/models/signed_retraction_spec.rb b/spec/models/signed_retraction_spec.rb new file mode 100644 index 000000000..de5b38da3 --- /dev/null +++ b/spec/models/signed_retraction_spec.rb @@ -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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b71da5ee6..a3abdba86 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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 diff --git a/spec/multi_server/server_spec.rb b/spec/multi_server/server_spec.rb index e8e01fea3..35f046af3 100644 --- a/spec/multi_server/server_spec.rb +++ b/spec/multi_server/server_spec.rb @@ -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