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/2] 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/2] 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