From 9d8ce0694829ee6bcbc88dfa37a0ee62b285e650 Mon Sep 17 00:00:00 2001 From: Billy Zhou Date: Wed, 23 Jan 2019 23:02:45 +0800 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20#2440=20-=20Request=20timeout=20w?= =?UTF-8?q?hile=20importing=20large=20attachments=20from=20Zendesk=20(than?= =?UTF-8?q?ks=20a=20lot=20to=20@anuzhin=20=F0=9F=98=8D).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ticket/comment/attachment/request.rb | 4 +-- .../ticket/comment/attachment/request_spec.rb | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 spec/lib/sequencer/unit/import/zendesk/ticket/comment/attachment/request_spec.rb diff --git a/lib/sequencer/unit/import/zendesk/ticket/comment/attachment/request.rb b/lib/sequencer/unit/import/zendesk/ticket/comment/attachment/request.rb index d1e5b84f9..02922a0c6 100644 --- a/lib/sequencer/unit/import/zendesk/ticket/comment/attachment/request.rb +++ b/lib/sequencer/unit/import/zendesk/ticket/comment/attachment/request.rb @@ -36,8 +36,8 @@ class Sequencer resource.content_url, {}, { - open_timeout: 10, - read_timeout: 60, + open_timeout: 20, + read_timeout: 240, }, ) end diff --git a/spec/lib/sequencer/unit/import/zendesk/ticket/comment/attachment/request_spec.rb b/spec/lib/sequencer/unit/import/zendesk/ticket/comment/attachment/request_spec.rb new file mode 100644 index 000000000..102ec9aa0 --- /dev/null +++ b/spec/lib/sequencer/unit/import/zendesk/ticket/comment/attachment/request_spec.rb @@ -0,0 +1,32 @@ +require 'rails_helper' + +RSpec.describe Sequencer::Unit::Import::Zendesk::Ticket::Comment::Attachment::Request, sequencer: :unit do + + context 'when fetching large attachements from Zendesk' do + + before(:all) do + + described_class.class_eval do + + private + + def failed? + false + end + end + end + + def mock_parameters + { + resource: double( + content_url: '' + ) + } + end + + it 'open timeout should be 20s and read timeout should be 240s' do + expect(UserAgent).to receive(:get).with(any_args, { open_timeout: 20, read_timeout: 240 }) + process(mock_parameters) + end + end +end