diff options
author | Jared Norman <jared@super.gd> | 2020-02-03 21:16:45 -0800 |
---|---|---|
committer | Jared Norman <jared@super.gd> | 2020-02-03 21:16:45 -0800 |
commit | 2e37b40e08cc4f2dcb31bf0bb3c41fb213669065 (patch) | |
tree | 30f880e756fb55cd23b5a334d748867d946b83e2 /spec | |
parent | 8c4f7f0d034348620e18936fd043c5cd15b8e453 (diff) |
Add support for modifying order params
Diffstat (limited to 'spec')
-rw-r--r-- | spec/super_good/solidus_taxjar/api_params_spec.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/super_good/solidus_taxjar/api_params_spec.rb b/spec/super_good/solidus_taxjar/api_params_spec.rb index e0a8766..8e9536f 100644 --- a/spec/super_good/solidus_taxjar/api_params_spec.rb +++ b/spec/super_good/solidus_taxjar/api_params_spec.rb @@ -141,6 +141,53 @@ RSpec.describe SuperGood::SolidusTaxJar::APIParams do ) end + context "when custom params are used" do + around do |example| + default = SuperGood::SolidusTaxJar.custom_order_params + SuperGood::SolidusTaxJar.custom_order_params = -> (order) { + { + nexus_addresses: [ + { + id: 'Main Location', + country: 'AU', + zip: 'NSW 2000', + city: 'Sydney', + street: '483 George St', + } + ] + } + } + example.run + SuperGood::SolidusTaxJar.custom_order_params = default + end + + it "returns params for fetching the tax for the order" do + expect(subject).to eq( + customer_id: "12345", + line_items: [{ + discount: 2.00, + id: order.line_items.first.id, + product_tax_code: "A_GEN_TAX", + quantity: 3, + unit_price: 10.00 + }], + nexus_addresses: [{ + id: 'Main Location', + country: 'AU', + zip: 'NSW 2000', + city: 'Sydney', + street: '483 George St', + }], + shipping: 3.01, + to_city: "Los Angeles", + to_country: "US", + to_state: "CA", + to_street: "475 N Beverly Dr", + to_zip: "90210" + ) + end + end + context "when the line item has zero quantity" do let(:line_item) do Spree::LineItem.new( |