mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Update variant_stock_spec for unsaved and soft-deleted cases
This commit is contained in:
@@ -90,13 +90,33 @@ describe VariantStock do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the variant has no stock item' do
|
||||
context 'when the variant has not been saved yet' do
|
||||
let(:variant) { build(:variant) }
|
||||
|
||||
it 'has no stock items' do
|
||||
expect(variant.stock_items.count).to eq 0
|
||||
end
|
||||
|
||||
it 'returns stock location default' do
|
||||
expect(variant.on_demand).to be_falsy
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the variant has been soft-deleted' do
|
||||
let(:deleted_variant) { create(:variant) }
|
||||
|
||||
before do
|
||||
deleted_variant.destroy
|
||||
end
|
||||
|
||||
it 'has no stock items' do
|
||||
expect(deleted_variant.stock_items.count).to eq 0
|
||||
end
|
||||
|
||||
it 'returns stock location default' do
|
||||
expect(deleted_variant.on_demand).to be_falsy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#on_demand=' do
|
||||
|
||||
Reference in New Issue
Block a user