mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-03 22:06:07 +00:00
Do not mutate config's state in specs
This commit is contained in:
@@ -75,17 +75,19 @@ module Spree
|
||||
end
|
||||
|
||||
describe "when tax on shipping is disabled" do
|
||||
before { Config.shipment_inc_vat = false }
|
||||
before do
|
||||
allow(Config).to receive(:shipment_inc_vat).and_return(false)
|
||||
end
|
||||
|
||||
it "records 0% tax on shipment adjustments" do
|
||||
Config.shipping_tax_rate = 0
|
||||
allow(Config).to receive(:shipping_tax_rate).and_return(0)
|
||||
order.shipments = [shipment]
|
||||
|
||||
expect(order.adjustments.first.included_tax).to eq(0)
|
||||
end
|
||||
|
||||
it "records 0% tax on shipments when a rate is set but shipment_inc_vat is false" do
|
||||
Config.shipping_tax_rate = 0.25
|
||||
allow(Config).to receive(:shipping_tax_rate).and_return(0.25)
|
||||
order.shipments = [shipment]
|
||||
|
||||
expect(order.adjustments.first.included_tax).to eq(0)
|
||||
@@ -93,10 +95,12 @@ module Spree
|
||||
end
|
||||
|
||||
describe "when tax on shipping is enabled" do
|
||||
before { Config.shipment_inc_vat = true }
|
||||
before do
|
||||
allow(Config).to receive(:shipment_inc_vat).and_return(true)
|
||||
end
|
||||
|
||||
it "takes the shipment adjustment tax included from the system setting" do
|
||||
Config.shipping_tax_rate = 0.25
|
||||
allow(Config).to receive(:shipping_tax_rate).and_return(0.25)
|
||||
order.shipments = [shipment]
|
||||
|
||||
# Finding the tax included in an amount that's already inclusive of tax:
|
||||
@@ -107,7 +111,7 @@ module Spree
|
||||
end
|
||||
|
||||
it "records 0% tax on shipments when shipping_tax_rate is not set" do
|
||||
Config.shipping_tax_rate = nil
|
||||
allow(Config).to receive(:shipping_tax_rate).and_return(0)
|
||||
order.shipments = [shipment]
|
||||
|
||||
expect(order.adjustments.first.included_tax).to eq(0)
|
||||
|
||||
@@ -229,8 +229,8 @@ describe Spree::Order do
|
||||
|
||||
context "with a taxed shipment" do
|
||||
before do
|
||||
Spree::Config.shipment_inc_vat = true
|
||||
Spree::Config.shipping_tax_rate = 0.25
|
||||
allow(Spree::Config).to receive(:shipment_inc_vat).and_return(true)
|
||||
allow(Spree::Config).to receive(:shipping_tax_rate).and_return(0.25)
|
||||
end
|
||||
|
||||
let!(:shipment) { create(:shipment_with, :shipping_method, shipping_method: shipping_method, order: order) }
|
||||
@@ -261,8 +261,8 @@ describe Spree::Order do
|
||||
|
||||
describe "getting the total tax" do
|
||||
before do
|
||||
Spree::Config.shipment_inc_vat = true
|
||||
Spree::Config.shipping_tax_rate = 0.25
|
||||
allow(Spree::Config).to receive(:shipment_inc_vat).and_return(true)
|
||||
allow(Spree::Config).to receive(:shipping_tax_rate).and_return(0.25)
|
||||
end
|
||||
|
||||
let(:order) { create(:order) }
|
||||
@@ -321,8 +321,8 @@ describe Spree::Order do
|
||||
end
|
||||
|
||||
before do
|
||||
Spree::Config.shipment_inc_vat = true
|
||||
Spree::Config.shipping_tax_rate = tax_rate15.amount
|
||||
allow(Spree::Config).to receive(:shipment_inc_vat).and_return(true)
|
||||
allow(Spree::Config).to receive(:shipping_tax_rate).and_return(tax_rate15.amount)
|
||||
end
|
||||
|
||||
let(:shipping_method) { create(:shipping_method, calculator: Spree::Calculator::FlatRate.new(preferred_amount: 46.0)) }
|
||||
|
||||
Reference in New Issue
Block a user