diff --git a/lib/diaspora/federated/retraction.rb b/lib/diaspora/federated/retraction.rb index 81c34d04e..f3e811a27 100644 --- a/lib/diaspora/federated/retraction.rb +++ b/lib/diaspora/federated/retraction.rb @@ -39,6 +39,10 @@ class Retraction logger.info "event=retraction status=complete target=#{data[:target_type]}:#{data[:target_guid]}" end + def public? + data[:target][:public] + end + private attr_reader :target diff --git a/spec/integration/dispatching_spec.rb b/spec/integration/dispatching_spec.rb index 83d4f0e32..2a18e8e09 100644 --- a/spec/integration/dispatching_spec.rb +++ b/spec/integration/dispatching_spec.rb @@ -1,19 +1,34 @@ -require 'spec_helper' +require "spec_helper" -describe "Dispatching", :type => :request do +describe "Dispatching", type: :request do context "a comment retraction on a public post" do - it "should trigger a private dispatch" do - luke, leia, raph = set_up_friends - # Luke has a public post and comments on it - post = FactoryGirl.create(:status_message, :public => true, :author => luke.person) + it "triggers a public dispatch" do + # Alice has a public post and comments on it + post = FactoryGirl.create(:status_message, public: true, author: alice.person) + + comment = alice.comment!(post, "awesomesauseum") - comment = luke.comment!(post, "awesomesauseum") - inlined_jobs do - # Luke now retracts his comment - expect(Postzord::Dispatcher::Public).not_to receive(:new) - expect(Postzord::Dispatcher::Private).to receive(:new).and_return(double(:post => true)) - luke.retract(comment) + # Alice now retracts her comment + expect(Diaspora::Federation::Dispatcher::Public).to receive(:new).and_return(double(dispatch: true)) + expect(Diaspora::Federation::Dispatcher::Private).not_to receive(:new) + alice.retract(comment) + end + end + end + + context "a comment retraction on a private post" do + it "triggers a private dispatch" do + # Alice has a private post and comments on it + post = alice.post(:status_message, text: "hello", to: alice.aspects.first) + + comment = alice.comment!(post, "awesomesauseum") + + inlined_jobs do + # Alice now retracts her comment + expect(Diaspora::Federation::Dispatcher::Public).not_to receive(:new) + expect(Diaspora::Federation::Dispatcher::Private).to receive(:new).and_return(double(dispatch: true)) + alice.retract(comment) end end end