Merge pull request #3347 from luisramos0/2-0-default-on-demand

[Spree Upgrade] Sets StockLocation.backorderable_default to false in test factories
This commit is contained in:
Pau Pérez Fabregat
2019-01-21 17:34:46 +01:00
committed by GitHub
5 changed files with 29 additions and 35 deletions

View File

@@ -135,7 +135,7 @@ describe VariantStock do
let(:variant) { build(:variant) }
it 'returns stock location default' do
expect(variant.on_demand).to be_truthy
expect(variant.on_demand).to be_falsy
end
end
end

View File

@@ -28,16 +28,20 @@ module Spree
end
it "computes the amount of fees" do
pickup = create(:payment_method)
order = create(:order)
expect(pickup.compute_amount(order)).to eq 0
transaction = create(:payment_method, calculator: Calculator::FlatRate.new(preferred_amount: 10))
expect(transaction.compute_amount(order)).to eq 10
transaction = create(:payment_method, calculator: Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10))
expect(transaction.compute_amount(order)).to eq 0
free_payment_method = create(:payment_method) # flat rate calculator with preferred_amount of 0
expect(free_payment_method.compute_amount(order)).to eq 0
flat_rate_payment_method = create(:payment_method, calculator: Calculator::FlatRate.new(preferred_amount: 10))
expect(flat_rate_payment_method.compute_amount(order)).to eq 10
flat_percent_payment_method = create(:payment_method, calculator: Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10))
expect(flat_percent_payment_method.compute_amount(order)).to eq 0
product = create(:product)
order.add_variant(product.master)
expect(transaction.compute_amount(order)).to eq 2.0
expect(flat_percent_payment_method.compute_amount(order)).to eq 2.0
end
end
end

View File

@@ -711,26 +711,6 @@ module Spree
e.variants(true).should be_empty
end
end
describe '#on_hand' do
let(:product) { create(:product) }
context 'when the product has variants' do
before { create(:variant, product: product) }
it 'returns the sum of the on_hand of its variants' do
expect(product.on_hand).to eq(Float::INFINITY)
end
end
context 'when the product has no variants' do
before { product.variants.destroy_all }
it 'returns the on_hand of the master' do
expect(product.on_hand).to eq(product.master.on_hand)
end
end
end
end
describe "product import" do