mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #13151 from mkllnk/dfc-stock-limit
Fix reset stock when importing DFC products
This commit is contained in:
@@ -15,6 +15,7 @@ class CatalogItemBuilder < DfcBuilder
|
||||
if limit.to_i.negative?
|
||||
variant.stock_items[0].backorderable = true
|
||||
else
|
||||
variant.stock_items[0].backorderable = false
|
||||
variant.stock_items[0].count_on_hand = limit
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,4 +28,23 @@ RSpec.describe DfcBuilder do
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".apply_stock" do
|
||||
let(:item) { CatalogItemBuilder.catalog_item(variant) }
|
||||
|
||||
it "updates from on-demand to out-of-stock" do
|
||||
variant.save!
|
||||
variant.on_demand = true
|
||||
variant.on_hand = -3
|
||||
|
||||
item.stockLimitation = 0
|
||||
|
||||
expect {
|
||||
CatalogItemBuilder.apply_stock(item, variant)
|
||||
variant.save!
|
||||
}
|
||||
.to change { variant.on_demand }.to(false)
|
||||
.and change { variant.on_hand }.to(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user