diff options
-rw-r--r-- | lib/super_good/solidus_taxjar/api.rb | 4 | ||||
-rw-r--r-- | spec/super_good/solidus_taxjar/api_spec.rb | 17 |
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/super_good/solidus_taxjar/api.rb b/lib/super_good/solidus_taxjar/api.rb index 45a32b7..61fecae 100644 --- a/lib/super_good/solidus_taxjar/api.rb +++ b/lib/super_good/solidus_taxjar/api.rb @@ -28,6 +28,10 @@ module SuperGood taxjar_client.update_order APIParams.transaction_params(order) end + def delete_transaction_for(order) + taxjar_client.delete_order order.number + end + private attr_reader :taxjar_client diff --git a/spec/super_good/solidus_taxjar/api_spec.rb b/spec/super_good/solidus_taxjar/api_spec.rb index 4c3a8e6..494496c 100644 --- a/spec/super_good/solidus_taxjar/api_spec.rb +++ b/spec/super_good/solidus_taxjar/api_spec.rb @@ -88,4 +88,21 @@ RSpec.describe SuperGood::SolidusTaxJar::API do it { is_expected.to eq({ some_kind_of: "response" }) } end + + describe "update_transaction_for" do + subject { api.delete_transaction_for order } + + let(:api) { described_class.new(taxjar_client: dummy_client) } + let(:dummy_client) { instance_double ::Taxjar::Client } + let(:order) { Spree::Order.new(number: "R111222333") } + + before do + allow(dummy_client) + .to receive(:delete_order) + .with("R111222333") + .and_return({ some_kind_of: "response" }) + end + + it { is_expected.to eq({ some_kind_of: "response" }) } + end end |