diff options
author | andrea longhi <andrea@spaghetticode.it> | 2020-01-13 20:17:08 +0100 |
---|---|---|
committer | andrea longhi <andrea@spaghetticode.it> | 2020-01-14 09:44:59 +0100 |
commit | 044bb66e25a440388431de27c67d437fe6cebfb6 (patch) | |
tree | bd9e909ede1da9afebcf4f66398b42d5e4b3e59b /spec | |
parent | 134be24f677be142b5ddeb889c45e80a19fd58c8 (diff) |
Add SolidusTaxJar::API#tax_rate_for
When calculating tax rates, the recommended endpoint from TaxJar
support for live calculations is `/v2/taxes`, the same used for
calculating order taxes, as it accounts for all factors like
sourcing or nexus, while the `/v2/rates` endpoint will return
the full combined rate for the queried location.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/super_good/solidus_taxjar/api_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/super_good/solidus_taxjar/api_spec.rb b/spec/super_good/solidus_taxjar/api_spec.rb index 0f890ca..8b0a5db 100644 --- a/spec/super_good/solidus_taxjar/api_spec.rb +++ b/spec/super_good/solidus_taxjar/api_spec.rb @@ -23,6 +23,30 @@ RSpec.describe SuperGood::SolidusTaxJar::API do it { is_expected.to eq({ some_kind_of: "response" }) } end + describe "tax_rate_for" do + subject { api.tax_rate_for address } + + let(:api) { described_class.new(taxjar_client: dummy_client) } + let(:dummy_client) { instance_double ::Taxjar::Client } + let(:address) { Spree::Address.new } + let(:tax_rate) { 0.04 } + let(:response) { double(rate: tax_rate) } + + before do + allow(SuperGood::SolidusTaxJar::APIParams) + .to receive(:tax_rate_address_params) + .with(address) + .and_return({ address: "params" }) + + allow(dummy_client) + .to receive(:tax_for_order) + .with({ address: "params" }) + .and_return(response) + end + + it { is_expected.to eq(tax_rate) } + end + describe "#tax_rates_for" do subject { api.tax_rates_for address } |