diff --git a/app/models/jobs/http_post.rb b/app/models/jobs/http_post.rb index a24b0cacf..b96d3aa9e 100644 --- a/app/models/jobs/http_post.rb +++ b/app/models/jobs/http_post.rb @@ -3,8 +3,7 @@ module Jobs @queue = :http def self.perform(url, body, tries_remaining) begin - request = RestClient::Resource.new(url, :xml => body, :timeout => 4) - request.post { |response, request, result, &block| + RestClient.post(url, :xml => body){ |response, request, result, &block| if [301, 302, 307].include? response.code response.follow_redirection(request, result, &block) else diff --git a/spec/models/jobs/http_post_spec.rb b/spec/models/jobs/http_post_spec.rb index 53746078b..18461996b 100644 --- a/spec/models/jobs/http_post_spec.rb +++ b/spec/models/jobs/http_post_spec.rb @@ -6,11 +6,11 @@ describe Jobs::HttpPost do @body = 'California' end it 'POSTs to a given URL' do - RestClient::Resource.should_receive(:new).with(@url, :xml=>@body, :timeout => 4) + RestClient.should_receive(:post).with(@url, {:xml=>@body}).and_return(true) Jobs::HttpPost.perform(@url, @body, 3) end it 'retries' do - RestClient::Resource.should_receive(:new).with(@url, :xml=>@body, :timeout => 4) + RestClient.should_receive(:post).with(@url, {:xml=>@body}).and_raise(SocketError) Resque.should_receive(:enqueue).with(Jobs::HttpPost, @url, @body, 1).once Jobs::HttpPost.perform(@url, @body, 2) end