From 01a726d9bd03e022ca1af95072529eae5f0477f5 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 17 Oct 2020 00:16:11 +0100 Subject: [PATCH] Fix stubbing of stock totals Recent changes to the way count_on_hand is summed in Spree::Stock::Quantifier mean the old method here will not work. Error: ``` 2) Spree::Variant#in_stock? when stock_items are not backorderable when stock_items out of stock return false if stock_items out of stock Failure/Error: expect(variant.in_stock?).to be_falsy expected: falsey value got: true # ./spec/models/spree/variant_spec.rb:241:in `block (5 levels) in ' ``` --- spec/models/spree/variant_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/spree/variant_spec.rb b/spec/models/spree/variant_spec.rb index 333b039f39..9a5ffbef05 100644 --- a/spec/models/spree/variant_spec.rb +++ b/spec/models/spree/variant_spec.rb @@ -234,7 +234,7 @@ module Spree context 'when stock_items out of stock' do before do allow_any_instance_of(Spree::StockItem).to receive_messages(backorderable: false) - allow_any_instance_of(Spree::StockItem).to receive_messages(count_on_hand: 0) + allow_any_instance_of(Spree::Stock::Quantifier).to receive_messages(total_on_hand: 0) end it 'return false if stock_items out of stock' do