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
|
@queue = :http
|
||||||
def self.perform(url, body, tries_remaining)
|
def self.perform(url, body, tries_remaining)
|
||||||
begin
|
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|
|
request.post { |response, request, result, &block|
|
||||||
if [301, 302, 307].include? response.code
|
if [301, 302, 307].include? response.code
|
||||||
response.follow_redirection(request, result, &block)
|
response.follow_redirection(request, result, &block)
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@ describe Jobs::HttpPost do
|
||||||
@body = '<xml>California</xml>'
|
@body = '<xml>California</xml>'
|
||||||
end
|
end
|
||||||
it 'POSTs to a given URL' do
|
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)
|
Jobs::HttpPost.perform(@url, @body, 3)
|
||||||
end
|
end
|
||||||
it 'retries' do
|
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
|
Resque.should_receive(:enqueue).with(Jobs::HttpPost, @url, @body, 1).once
|
||||||
Jobs::HttpPost.perform(@url, @body, 2)
|
Jobs::HttpPost.perform(@url, @body, 2)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue