From 5bcc49a61cd6933f6f091b5a94c0fbd239384b2d Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Fri, 7 Sep 2018 11:56:26 +0100 Subject: [PATCH 1/2] Removed calls to the now inexistent order.create_shipment! from specs --- spec/models/spree/adjustment_spec.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spec/models/spree/adjustment_spec.rb b/spec/models/spree/adjustment_spec.rb index fa24de3122..cc1022e34a 100644 --- a/spec/models/spree/adjustment_spec.rb +++ b/spec/models/spree/adjustment_spec.rb @@ -66,7 +66,6 @@ module Spree let(:adjustment) { order.adjustments(:reload).shipping.first } it "has a shipping charge of $50" do - order.create_shipment! adjustment.amount.should == 50 end @@ -74,7 +73,6 @@ module Spree it "records 0% tax on shipment adjustments" do Config.shipment_inc_vat = false Config.shipping_tax_rate = 0 - order.create_shipment! adjustment.included_tax.should == 0 end @@ -82,7 +80,6 @@ module Spree it "records 0% tax on shipments when a rate is set but shipment_inc_vat is false" do Config.shipment_inc_vat = false Config.shipping_tax_rate = 0.25 - order.create_shipment! adjustment.included_tax.should == 0 end @@ -92,7 +89,6 @@ module Spree before do Config.shipment_inc_vat = true Config.shipping_tax_rate = 0.25 - order.create_shipment! end it "takes the shipment adjustment tax included from the system setting" do @@ -106,14 +102,12 @@ module Spree it "records 0% tax on shipments when shipping_tax_rate is not set" do Config.shipment_inc_vat = true Config.shipping_tax_rate = nil - order.create_shipment! adjustment.included_tax.should == 0 end it "records 0% tax on shipments when the distributor does not charge sales tax" do order.distributor.update_attributes! charges_sales_tax: false - order.reload.create_shipment! adjustment.included_tax.should == 0 end From 2f1616a286e1c286994725d12d1675a79516ee66 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Sun, 9 Sep 2018 23:24:19 +0100 Subject: [PATCH 2/2] Changed reference from order.shipping_method to order.shipments in adjustment_spec --- spec/factories.rb | 10 ++++++++++ spec/models/spree/adjustment_spec.rb | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/spec/factories.rb b/spec/factories.rb index c405e09c9a..36dee4dd26 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -280,6 +280,16 @@ FactoryBot.define do after(:create) { |c| c.set_preference(:per_kg, 0.5); c.save! } end + factory :shipping_method_with_flat_rate, parent: :shipping_method do + calculator { Spree::Calculator::FlatRate.new(preferred_amount: 50.0) } + end + + factory :shipment_with_flat_rate, parent: :shipment do + after(:create) do |shipment| + shipment.add_shipping_method(create(:shipping_method_with_flat_rate), true) + end + end + factory :order_with_totals_and_distribution, :parent => :order do #possibly called :order_with_line_items in newer Spree distributor { create(:distributor_enterprise) } order_cycle { create(:simple_order_cycle) } diff --git a/spec/models/spree/adjustment_spec.rb b/spec/models/spree/adjustment_spec.rb index cc1022e34a..e64b0e14ba 100644 --- a/spec/models/spree/adjustment_spec.rb +++ b/spec/models/spree/adjustment_spec.rb @@ -59,10 +59,10 @@ module Spree end describe "Shipment adjustments" do - let!(:order) { create(:order, distributor: hub, shipping_method: shipping_method) } + let!(:shipment) { create(:shipment_with_flat_rate) } + let!(:order) { create(:order, distributor: hub, shipments: [shipment]) } let(:hub) { create(:distributor_enterprise, charges_sales_tax: true) } let!(:line_item) { create(:line_item, order: order) } - let(:shipping_method) { create(:shipping_method, calculator: Calculator::FlatRate.new(preferred_amount: 50.0)) } let(:adjustment) { order.adjustments(:reload).shipping.first } it "has a shipping charge of $50" do