forked from avadev/AvaTax-REST-V2-Ruby-SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use inline Oj settings when necessary (#2)
Setting `Oj.default_options` global setting causes unexpected sid effects for applications where gem is being included. Instead the `bigdecimal_load: :bigdecimal` mode can be applied inline.
- Loading branch information
Showing
5 changed files
with
51 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
|
||
module AvaTax | ||
class API | ||
|
||
attr_accessor *Configuration::VALID_OPTIONS_KEYS | ||
|
||
def initialize(options={}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require_relative "../spec_helper" | ||
|
||
describe AvaTax::API do | ||
context "connection" do | ||
|
||
it "uses custom ParseOj for regular config" do | ||
faraday_instance_double = double.as_null_object | ||
|
||
expect(Faraday).to receive(:new).and_yield(faraday_instance_double) | ||
expect(faraday_instance_double).to receive(:response).with(:oj, { content_type: /\bjson$/ }) | ||
|
||
# default setting | ||
expect(Oj.default_options[:bigdecimal_load]).to eq(:auto) | ||
|
||
AvaTax::API.new.send(:connection) | ||
end | ||
|
||
it "uses custom ParseOjWithBigDecimal when response_big_decimal_conversion provided" do | ||
faraday_instance_double = double.as_null_object | ||
|
||
expect(Faraday).to receive(:new).and_yield(faraday_instance_double) | ||
expect(faraday_instance_double).to receive(:response).with(:oj_with_bigdecimal, { content_type: /\bjson$/ }) | ||
|
||
# default setting | ||
expect(Oj.default_options[:bigdecimal_load]).to eq(:auto) | ||
|
||
AvaTax::API.new(response_big_decimal_conversion: true).send(:connection) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters