Skip to content

Commit 205f06f

Browse files
Merge branch 'master' into 21.3.0
2 parents c380983 + 0da03b2 commit 205f06f

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

lib/avatax/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module Configuration
2929
DEFAULT_USER_AGENT = "AvaTax Ruby Gem #{AvaTax::VERSION}".freeze
3030
DEFAULT_USERNAME = nil
3131
DEFAULT_PASSWORD = nil
32-
DEFAULT_CONNECTION_OPTIONS = {}
32+
DEFAULT_CONNECTION_OPTIONS = {request: {timeout: 1200}} # timeout in seconds
3333
DEFAULT_LOGGER = false
3434
DEFAULT_CUSTOM_LOGGER = nil
3535
DEFAULT_CUSTOM_LOGGER_OPTIONS = {}

lib/avatax/request.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ def delete(path, options={})
2222

2323
def request(method, path, model, options={})
2424
response = connection.send(method) do |request|
25-
# timeout in seconds
26-
request.options['timeout'] = 1200
2725
case method
2826
when :get, :delete
2927
request.url("#{URI.encode(path)}?#{URI.encode_www_form(options)}")

spec/avatax/request_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require File.expand_path('../../spec_helper', __FILE__)
2+
3+
describe AvaTax::Request do
4+
5+
describe ".request" do
6+
it "should default to a 1200 second timeout" do
7+
@client.faraday_response = true
8+
response = @client.request(:get, 'path', 'model')
9+
expect(response.env.request['timeout']).to eq(1200)
10+
end
11+
12+
it "should allow setting a custom timeout" do
13+
@client.faraday_response = true
14+
@client.connection_options = {
15+
request: {
16+
open_timeout: 5,
17+
timeout: 10
18+
}
19+
}
20+
response = @client.request(:get, 'path', 'model')
21+
expect(response.env.request['open_timeout']).to eq(5)
22+
expect(response.env.request['timeout']).to eq(10)
23+
end
24+
end
25+
end

0 commit comments

Comments
 (0)