mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-07 22:46:06 +00:00
Merge pull request #3537 from Matt-Yorkley/pi/on_demand_error
Fix nil values in on_hand column
This commit is contained in:
@@ -254,6 +254,7 @@ module ProductImport
|
||||
new_product = Spree::Product.new
|
||||
new_product.assign_attributes(entry.attributes.except('id'))
|
||||
new_product.supplier_id = entry.producer_id
|
||||
entry.on_hand = 0 if entry.on_hand.nil?
|
||||
|
||||
if new_product.valid?
|
||||
entry.validates_as = 'new_product' unless entry.errors?
|
||||
|
||||
@@ -50,7 +50,7 @@ describe ProductImport::ProductImporter do
|
||||
csv << ["Potatoes", "User Enterprise", "Vegetables", "6", "6.50", "2", "kg", "", ""]
|
||||
csv << ["Pea Soup", "User Enterprise", "Vegetables", "8", "5.50", "750", "ml", "", "0"]
|
||||
csv << ["Salad", "User Enterprise", "Vegetables", "7", "4.50", "1", "", "bags", ""]
|
||||
csv << ["Hot Cross Buns", "User Enterprise", "Cake", "7", "3.50", "1", "", "buns", "1"]
|
||||
csv << ["Hot Cross Buns", "User Enterprise", "Cake", nil, "3.50", "1", "", "buns", "1"]
|
||||
end
|
||||
File.write('/tmp/test-m.csv', csv_data)
|
||||
file = File.new('/tmp/test-m.csv')
|
||||
@@ -122,7 +122,8 @@ describe ProductImport::ProductImporter do
|
||||
|
||||
buns = Spree::Product.find_by_name('Hot Cross Buns')
|
||||
expect(buns.supplier).to eq enterprise
|
||||
# buns.on_hand).to eq Infinity
|
||||
expect(buns.on_hand).to eq Float::INFINITY
|
||||
expect(buns.count_on_hand).to eq 0
|
||||
expect(buns.price).to eq 3.50
|
||||
expect(buns.unit_value).to eq 1
|
||||
expect(buns.variant_unit).to eq 'items'
|
||||
|
||||
Reference in New Issue
Block a user