diff --git a/lib/postzord/dispatcher.rb b/lib/postzord/dispatcher.rb index 67032dfd1adadaf654014a2b6e2329f55fb1e28e..651087d5bf5aa7ee55f1014580fef707ebf8d257 100644 --- a/lib/postzord/dispatcher.rb +++ b/lib/postzord/dispatcher.rb @@ -150,7 +150,7 @@ class Postzord::Dispatcher end end if @object.instance_of?(SignedRetraction) - services.each do |service| + services.select { |service| service.respond_to? :delete_post }.each do |service| Resque.enqueue(Jobs::DeletePostFromService, service.id, @object.target.facebook_id) end end diff --git a/spec/lib/postzord/dispatcher_spec.rb b/spec/lib/postzord/dispatcher_spec.rb index 2a8c3492be09f84dbbc53c7b2449396a440d391e..7df98d97b361e6c6ebe2f0a893b121465f294b01 100644 --- a/spec/lib/postzord/dispatcher_spec.rb +++ b/spec/lib/postzord/dispatcher_spec.rb @@ -317,10 +317,18 @@ describe Postzord::Dispatcher do retraction = SignedRetraction.build(alice, FactoryGirl.create(:status_message)) mailman = Postzord::Dispatcher.build(alice, retraction, :url => "http://joindiaspora.com/p/123", :services => [@service]) - Resque.stub!(:enqueue).with(Jobs::DeletePostFromService, anything, anything) Resque.should_receive(:enqueue).with(Jobs::DeletePostFromService, anything, anything) mailman.post end + + it "doesn't queue a job if we can't delete the post from the service" do + retraction = SignedRetraction.build(alice, FactoryGirl.create(:status_message)) + service = Services::Twitter.new(access_token: "nope") + mailman = Postzord::Dispatcher.build(alice, retraction, :url => "http://joindiaspora.com/p/123", :services => [service]) + + Resque.should_not_receive(:enqueue).with(Jobs::DeletePostFromService, anything, anything) + mailman.post + end end describe '#and_notify_local_users' do