Skip to content

Commit

Permalink
Merge pull request #96 from avadev/pr82
Browse files Browse the repository at this point in the history
21.1.2 Update - From pr 82
  • Loading branch information
contygm authored Feb 23, 2021
2 parents bd7ecd2 + 02c84fa commit 0da03b2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/avatax/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module Configuration
DEFAULT_USER_AGENT = "AvaTax Ruby Gem #{AvaTax::VERSION}".freeze
DEFAULT_USERNAME = nil
DEFAULT_PASSWORD = nil
DEFAULT_CONNECTION_OPTIONS = {}
DEFAULT_CONNECTION_OPTIONS = {request: {timeout: 1200}} # timeout in seconds
DEFAULT_LOGGER = false
DEFAULT_CUSTOM_LOGGER = nil
DEFAULT_CUSTOM_LOGGER_OPTIONS = {}
Expand Down
2 changes: 0 additions & 2 deletions lib/avatax/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ def delete(path, options={})

def request(method, path, model, options={})
response = connection.send(method) do |request|
# timeout in seconds
request.options['timeout'] = 1200
case method
when :get, :delete
request.url("#{URI.encode(path)}?#{URI.encode_www_form(options)}")
Expand Down
2 changes: 1 addition & 1 deletion lib/avatax/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module AvaTax
VERSION = '21.1.1'.freeze unless defined?(::AvaTax::VERSION)
VERSION = '21.1.2'.freeze unless defined?(::AvaTax::VERSION)
end
25 changes: 25 additions & 0 deletions spec/avatax/request_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require File.expand_path('../../spec_helper', __FILE__)

describe AvaTax::Request do

describe ".request" do
it "should default to a 1200 second timeout" do
@client.faraday_response = true
response = @client.request(:get, 'path', 'model')
expect(response.env.request['timeout']).to eq(1200)
end

it "should allow setting a custom timeout" do
@client.faraday_response = true
@client.connection_options = {
request: {
open_timeout: 5,
timeout: 10
}
}
response = @client.request(:get, 'path', 'model')
expect(response.env.request['open_timeout']).to eq(5)
expect(response.env.request['timeout']).to eq(10)
end
end
end

0 comments on commit 0da03b2

Please sign in to comment.