DG MS; remove unusused job

This commit is contained in:
danielgrippi 2011-09-15 11:01:25 -07:00
parent 380b980f8b
commit cfa260927d
2 changed files with 0 additions and 48 deletions

View file

@ -1,30 +0,0 @@
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module Job
class HttpPost < Base
@queue = :http
NUM_TRIES = 3
def self.perform(url, body, tries_remaining = NUM_TRIES)
begin
body = CGI::escape(body)
RestClient.post(url, :xml => body){ |response, request, result, &block|
if [301, 302, 307].include? response.code
response.follow_redirection(request, result, &block)
else
response.return!(request, result, &block)
end
}
rescue Exception => e
unless tries_remaining <= 1
Resque.enqueue(self, url, body, tries_remaining -1)
else
raise e
end
end
end
end
end

View file

@ -1,18 +0,0 @@
require 'spec_helper'
describe Job::HttpPost do
before do
@url = 'example.org/things/on/fire'
@body = '<xml>California</xml>'
@escaped_body = CGI::escape(@body)
end
it 'POSTs to a given URL' do
RestClient.should_receive(:post).with(@url, {:xml=>@escaped_body}).and_return(true)
Job::HttpPost.perform(@url, @body, 3)
end
it 'retries' do
RestClient.should_receive(:post).with(@url, {:xml=>@escaped_body}).and_raise(SocketError)
Resque.should_receive(:enqueue).with(Job::HttpPost, @url, @escaped_body, 1).once
Job::HttpPost.perform(@url, @body, 2)
end
end