Commit 7a89d8b1 authored by Jonne Haß's avatar Jonne Haß
Browse files

only try to delete a post from a service if we're able to

parent 1256fda2
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment