diff options
author | Jared Norman <jared@super.gd> | 2019-04-11 13:57:53 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-11 13:57:53 +1200 |
commit | cb5f842ac7490330c0818e4ccb1b178844bdf7a6 (patch) | |
tree | 4a19b79ebc091b26ef1a2d99506e22d12ffde899 /spec/super_good/solidus_taxjar | |
parent | 0cb25e229937e705341c26961181fa26d6faa562 (diff) | |
parent | cb740a35890e9aad7f5206f4c4759c497cbff115 (diff) |
Merge pull request #10 from SuperGoodSoft/feature/empty-line-items
Don't send line items with 0 quantity
Diffstat (limited to 'spec/super_good/solidus_taxjar')
-rw-r--r-- | spec/super_good/solidus_taxjar/api_params_spec.rb | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/spec/super_good/solidus_taxjar/api_params_spec.rb b/spec/super_good/solidus_taxjar/api_params_spec.rb index abc8a23..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,12 +210,40 @@ 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 subject { described_class.refund_params(reimbursement) } - it "returns params for creating/updatingin a refund" do + it "returns params for creating/updating a refund" do expect(subject).to eq({ amount: BigDecimal("300.00"), sales_tax: BigDecimal("33.33"), |