diff options
author | Jared Norman <jared@super.gd> | 2019-04-11 13:49:55 +1200 |
---|---|---|
committer | Jared Norman <jared@super.gd> | 2019-04-11 13:53:14 +1200 |
commit | cb740a35890e9aad7f5206f4c4759c497cbff115 (patch) | |
tree | 4a19b79ebc091b26ef1a2d99506e22d12ffde899 /spec/super_good | |
parent | 3ad0d4d02a6a5c284c695d82e3064be33168be6e (diff) |
Avoid sending 0 quantity line items
Diffstat (limited to 'spec/super_good')
-rw-r--r-- | spec/super_good/solidus_taxjar/api_params_spec.rb | 54 |
1 files changed, 54 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 3688d2f..9c8696f 100644 --- a/spec/super_good/solidus_taxjar/api_params_spec.rb +++ b/spec/super_good/solidus_taxjar/api_params_spec.rb @@ -140,6 +140,32 @@ RSpec.describe SuperGood::SolidusTaxJar::APIParams do }] ) end + + context "when the line item has zero quantity" do + let(:line_item) do + Spree::LineItem.new( + variant: variant, + price: 10, + quantity: 0, + promo_total: -2, + additional_tax_total: 4 + ) + end + + it "excludes the line item" do + expect(subject).to eq( + to_country: "US", + to_zip: "90210", + to_city: "Los Angeles", + to_state: "CA", + to_street: "475 N Beverly Dr", + + shipping: 3.01, + + line_items: [] + ) + end + end end describe "#address_params" do @@ -184,6 +210,34 @@ RSpec.describe SuperGood::SolidusTaxJar::APIParams do }] }) end + + context "when the line item has 0 quantity" do + let(:line_item) do + Spree::LineItem.new( + variant: variant, + price: 10, + quantity: 0, + promo_total: -2, + additional_tax_total: 4 + ) + end + + it "excludes the line item" do + expect(subject).to eq({ + amount: BigDecimal("113.58"), + sales_tax: BigDecimal("9.87"), + shipping: BigDecimal("3.01"), + to_city: "Los Angeles", + to_country: "US", + to_state: "CA", + to_street: "475 N Beverly Dr", + to_zip: "90210", + transaction_date: "2018-03-06T12:10:33Z", + transaction_id: "R111222333", + line_items: [] + }) + end + end end describe "#refund_params" do |