summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/super_good/solidus_taxjar/api.rb4
-rw-r--r--spec/super_good/solidus_taxjar/api_spec.rb22
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/super_good/solidus_taxjar/api.rb b/lib/super_good/solidus_taxjar/api.rb
index 301fba4..45a32b7 100644
--- a/lib/super_good/solidus_taxjar/api.rb
+++ b/lib/super_good/solidus_taxjar/api.rb
@@ -24,6 +24,10 @@ module SuperGood
taxjar_client.create_order APIParams.transaction_params(order)
end
+ def update_transaction_for(order)
+ taxjar_client.update_order APIParams.transaction_params(order)
+ 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 0bfb67a..4c3a8e6 100644
--- a/spec/super_good/solidus_taxjar/api_spec.rb
+++ b/spec/super_good/solidus_taxjar/api_spec.rb
@@ -66,4 +66,26 @@ RSpec.describe SuperGood::SolidusTaxJar::API do
it { is_expected.to eq({ some_kind_of: "response" }) }
end
+
+ describe "update_transaction_for" do
+ subject { api.update_transaction_for order }
+
+ let(:api) { described_class.new(taxjar_client: dummy_client) }
+ let(:dummy_client) { instance_double ::Taxjar::Client }
+ let(:order) { Spree::Order.new }
+
+ before do
+ allow(SuperGood::SolidusTaxJar::APIParams)
+ .to receive(:transaction_params)
+ .with(order)
+ .and_return({ transaction: "params" })
+
+ allow(dummy_client)
+ .to receive(:update_order)
+ .with({ transaction: "params" })
+ .and_return({ some_kind_of: "response" })
+ end
+
+ it { is_expected.to eq({ some_kind_of: "response" }) }
+ end
end