Disable typhoeus everywhere but the HTTPMulti specs
This commit is contained in:
parent
8b4c8e77cb
commit
080f08187d
5 changed files with 33 additions and 13 deletions
|
|
@ -8,6 +8,8 @@ module Job
|
|||
class HttpMulti < Base
|
||||
@queue = :http
|
||||
|
||||
Hydra = Typhoeus::Hydra
|
||||
Request = Typhoeus::Request
|
||||
MAX_RETRIES = 3
|
||||
OPTS = {:max_redirects => 3, :timeout => 5000, :method => :post}
|
||||
|
||||
|
|
@ -19,13 +21,13 @@ module Job
|
|||
|
||||
failed_request_people = []
|
||||
|
||||
hydra = Typhoeus::Hydra.new
|
||||
hydra = Hydra.new
|
||||
people.each do |person|
|
||||
|
||||
url = person.receive_url
|
||||
xml = salmon.xml_for(person)
|
||||
|
||||
request = Typhoeus::Request.new(url, OPTS.merge(:params => {:xml => CGI::escape(xml)}))
|
||||
request = Request.new(url, OPTS.merge(:params => {:xml => CGI::escape(xml)}))
|
||||
|
||||
request.on_complete do |response|
|
||||
if response.code >= 300 && response.code < 400
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Job::HttpMulti do
|
||||
before :all do
|
||||
enable_typhoeus
|
||||
end
|
||||
after :all do
|
||||
disable_typhoeus
|
||||
end
|
||||
|
||||
before do
|
||||
@people = [Factory(:person), Factory(:person)]
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ RSpec.configure do |config|
|
|||
end
|
||||
end
|
||||
|
||||
disable_typhoeus
|
||||
ProcessedImage.enable_processing = false
|
||||
|
||||
def set_up_friends
|
||||
|
|
|
|||
22
spec/support/fake_typhoeus.rb
Normal file
22
spec/support/fake_typhoeus.rb
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
class FakeHydra
|
||||
def queue(*args); end
|
||||
def run; end
|
||||
end
|
||||
|
||||
class FakeHydraRequest
|
||||
def initialize(*args); end
|
||||
def on_complete; end
|
||||
end
|
||||
|
||||
def disable_typhoeus
|
||||
silence_warnings do
|
||||
Job::HttpMulti.const_set('Hydra', FakeHydra)
|
||||
Job::HttpMulti.const_set('Request', FakeHydraRequest)
|
||||
end
|
||||
end
|
||||
def enable_typhoeus
|
||||
silence_warnings do
|
||||
Job::HttpMulti.const_set('Hydra', Typhoeus::Hydra)
|
||||
Job::HttpMulti.const_set('Request', Typhoeus::Request)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#class Typhoeus::Hydra
|
||||
# def initialize
|
||||
# end
|
||||
|
||||
# def queue(*args)
|
||||
# end
|
||||
|
||||
# def run
|
||||
# end
|
||||
#end
|
||||
|
||||
Loading…
Reference in a new issue