request -> resource
This commit is contained in:
parent
737e6084df
commit
d7407b7aa6
2 changed files with 3 additions and 3 deletions
|
|
@ -3,7 +3,7 @@ module Jobs
|
|||
@queue = :http
|
||||
def self.perform(url, body, tries_remaining)
|
||||
begin
|
||||
request = RestClient::Request.new(url, :xml => body, :timeout => 4)
|
||||
request = RestClient::Resource.new(url, :xml => body, :timeout => 4)
|
||||
request.post { |response, request, result, &block|
|
||||
if [301, 302, 307].include? response.code
|
||||
response.follow_redirection(request, result, &block)
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ describe Jobs::HttpPost do
|
|||
@body = '<xml>California</xml>'
|
||||
end
|
||||
it 'POSTs to a given URL' do
|
||||
RestClient::Request.should_receive(:new).with(@url, :xml=>@body, :timeout => 4)
|
||||
RestClient::Resource.should_receive(:new).with(@url, :xml=>@body, :timeout => 4)
|
||||
Jobs::HttpPost.perform(@url, @body, 3)
|
||||
end
|
||||
it 'retries' do
|
||||
RestClient::Request.should_receive(:new).with(@url, :xml=>@body, :timeout => 4)
|
||||
RestClient::Resource.should_receive(:new).with(@url, :xml=>@body, :timeout => 4)
|
||||
Resque.should_receive(:enqueue).with(Jobs::HttpPost, @url, @body, 1).once
|
||||
Jobs::HttpPost.perform(@url, @body, 2)
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue