From fffbe616f2d7e04b1ee4e279f50300f0205ab1f5 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Wed, 11 Jan 2017 17:24:47 +0100 Subject: [PATCH 1/3] Updates for Solidus >=1.3 Solidus 1.3 introduced persisted shipping rate taxes. This updates the shipping_rate spec to reflect the changes made in Solidus 1.3. Also makes sure that this extension not installs for Solidus v2.1, as it is not compatible to Solidus 2.1 yet. --- .travis.yml | 6 ++++-- Gemfile | 2 +- solidus_avatax.gemspec | 2 +- spec/models/spree/shipping_rate_spec.rb | 17 +++++++++++++---- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3dd8631..1a32091 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,10 @@ env: matrix: - SOLIDUS_BRANCH=v1.3 DB=mysql - SOLIDUS_BRANCH=v1.3 DB=postgres - - SOLIDUS_BRANCH=master DB=mysql - - SOLIDUS_BRANCH=master DB=postgres + - SOLIDUS_BRANCH=v1.4 DB=mysql + - SOLIDUS_BRANCH=v1.4 DB=postgres + - SOLIDUS_BRANCH=v2.0 DB=mysql + - SOLIDUS_BRANCH=v2.0 DB=postgres script: - bundle exec rake test_app - bundle exec rspec diff --git a/Gemfile b/Gemfile index 1b17d76..a3c161b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source "https://rubygems.org" -branch = ENV.fetch('SOLIDUS_BRANCH', 'master') +branch = ENV.fetch('SOLIDUS_BRANCH', 'v1.4') gem "solidus", github: "solidusio/solidus", branch: branch gem "solidus_auth_devise", "~> 1.0" diff --git a/solidus_avatax.gemspec b/solidus_avatax.gemspec index 5f91ce8..f405540 100644 --- a/solidus_avatax.gemspec +++ b/solidus_avatax.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |s| s.require_path = "lib" s.requirements << "none" - s.add_dependency "solidus_core", ">= 1.3.0.alpha", "< 1.4" + s.add_dependency "solidus_core", ">= 1.3.0", "< 2.1" s.add_dependency "hashie", "~> 2.l.5" s.add_dependency "multi_json" s.add_dependency "Avatax_TaxService", "~> 2.0.0" diff --git a/spec/models/spree/shipping_rate_spec.rb b/spec/models/spree/shipping_rate_spec.rb index d367ba7..ccb7a69 100644 --- a/spec/models/spree/shipping_rate_spec.rb +++ b/spec/models/spree/shipping_rate_spec.rb @@ -1,19 +1,28 @@ require 'spec_helper' describe Spree::ShippingRate do + let!(:tax_rate) do + rate = Spree::TaxRate.first + rate.zone.countries << shipment.order.ship_address.country + rate + end + let(:shipping_rate) do shipment.shipping_rates.create!({ - tax_rate: Spree::TaxRate.first, shipping_method: shipping_method, cost: 10.00, - selected: true, + selected: true }) end let(:shipment) { create(:shipment) } - let(:shipping_method) { create(:shipping_method) } + let(:shipping_method) { create(:shipping_method, tax_category: tax_rate.tax_category) } + + before do + Spree::Config.shipping_rate_taxer_class.new.tax(shipping_rate) + end it 'calculates shipping rate taxes as 0' do - expect(shipping_rate.calculate_tax_amount).to eq 0 + expect(shipping_rate.taxes.first.amount).to eq 0 end end From 0002abfe4c0c7759c92ceb69a0d3d2e027c4ac20 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Wed, 11 Jan 2017 18:16:53 +0100 Subject: [PATCH 2/3] Build recent ruby version on travis Rake 2.0 and Rails 5 need at least Ruby 2.2.2 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1a32091..eb817f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,4 @@ script: - bundle exec rake test_app - bundle exec rspec rvm: - - 2.1.8 + - 2.3.3 From 1df6862b0c1e51222c41022873466f37dfd18b9c Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Wed, 11 Jan 2017 18:02:54 +0100 Subject: [PATCH 3/3] Updates for Solidus >= 2.1 Solidus 2.1 merged the ItemAdjustments class into the OrderUpdater class. This removes the extra calls for ItemAdjustements in SpreeAvatax::SalesShared class since the order updater now handles creating adjustments on its own. --- .travis.yml | 10 ++++------ Gemfile | 2 +- app/models/spree_avatax/sales_shared.rb | 4 ---- solidus_avatax.gemspec | 2 +- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index eb817f9..e03ddc7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,12 +3,10 @@ cache: bundler language: ruby env: matrix: - - SOLIDUS_BRANCH=v1.3 DB=mysql - - SOLIDUS_BRANCH=v1.3 DB=postgres - - SOLIDUS_BRANCH=v1.4 DB=mysql - - SOLIDUS_BRANCH=v1.4 DB=postgres - - SOLIDUS_BRANCH=v2.0 DB=mysql - - SOLIDUS_BRANCH=v2.0 DB=postgres + - SOLIDUS_BRANCH=v2.1 DB=mysql + - SOLIDUS_BRANCH=v2.1 DB=postgres + - SOLIDUS_BRANCH=master DB=mysql + - SOLIDUS_BRANCH=master DB=postgres script: - bundle exec rake test_app - bundle exec rspec diff --git a/Gemfile b/Gemfile index a3c161b..1b17d76 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source "https://rubygems.org" -branch = ENV.fetch('SOLIDUS_BRANCH', 'v1.4') +branch = ENV.fetch('SOLIDUS_BRANCH', 'master') gem "solidus", github: "solidusio/solidus", branch: branch gem "solidus_auth_devise", "~> 1.0" diff --git a/app/models/spree_avatax/sales_shared.rb b/app/models/spree_avatax/sales_shared.rb index 344f368..f872e88 100644 --- a/app/models/spree_avatax/sales_shared.rb +++ b/app/models/spree_avatax/sales_shared.rb @@ -43,7 +43,6 @@ def update_taxes(order, tax_line_data) finalized: true, # this tells spree not to automatically recalculate avatax tax adjustments }) - Spree::ItemAdjustments.new(record).update record.save! end @@ -119,9 +118,6 @@ def reset_tax_attributes(order) adjustment_total: 0, included_tax_total: 0, }) - - Spree::ItemAdjustments.new(taxable_record).update - taxable_record.save! end order.update_attributes!({ diff --git a/solidus_avatax.gemspec b/solidus_avatax.gemspec index f405540..20b1421 100644 --- a/solidus_avatax.gemspec +++ b/solidus_avatax.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |s| s.require_path = "lib" s.requirements << "none" - s.add_dependency "solidus_core", ">= 1.3.0", "< 2.1" + s.add_dependency "solidus_core", ">= 2.1.0.rc1", "< 3" s.add_dependency "hashie", "~> 2.l.5" s.add_dependency "multi_json" s.add_dependency "Avatax_TaxService", "~> 2.0.0"