add spec & change syntax in http_multi
This commit is contained in:
parent
ed029b2fbd
commit
995996add1
2 changed files with 14 additions and 5 deletions
|
|
@ -25,7 +25,6 @@ module Jobs
|
|||
[user_id, encoded_object_xml, @failed_people, dispatcher_class_as_string]
|
||||
end
|
||||
|
||||
|
||||
def self.perform(user_id, encoded_object_xml, person_ids, dispatcher_class_as_string)
|
||||
user = User.find(user_id)
|
||||
people = Person.where(:id => person_ids)
|
||||
|
|
@ -38,7 +37,7 @@ module Jobs
|
|||
|
||||
@failed_people = hydra.failed_people
|
||||
|
||||
if not @failed_people.empty?
|
||||
unless @failed_people.empty?
|
||||
if self.retry_limit_reached?
|
||||
msg = "event=http_multi_abandon sender_id=#{user_id} failed_recipient_ids='[#{@failed_people.join(', ')}]'"
|
||||
Rails.logger.info(msg)
|
||||
|
|
@ -47,6 +46,5 @@ module Jobs
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -28,7 +28,18 @@ describe Jobs::HttpMulti do
|
|||
Typhoeus::Hydra.stub!(:new).and_return(@hydra)
|
||||
|
||||
people_ids = @people.map{ |p| p.id }
|
||||
lambda {
|
||||
Jobs::HttpMulti.perform(bob.id, @post_xml, people_ids, "Postzord::Dispatcher::Private")
|
||||
}.should_not raise_error
|
||||
end
|
||||
|
||||
it 'retries' do
|
||||
person = @people[0]
|
||||
@hydra.stub(:post, person.receive_url).and_return(@failed_response)
|
||||
Typhoeus::Hydra.stub!(:new).and_return(@hydra)
|
||||
lambda {
|
||||
Jobs::HttpMulti.perform(bob.id, @post_xml, [person.id], "Postzord::Dispatcher::Private")
|
||||
}.should raise_error /retry/
|
||||
end
|
||||
|
||||
it 'generates encrypted xml for people' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue