Update variant_stock_spec for unsaved and soft-deleted cases

This commit is contained in:
Matt-Yorkley
2020-04-29 18:26:17 +02:00
parent 4054bdd722
commit f2cd122ec8

View File

@@ -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