mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-31 21:37:16 +00:00
Do not set unit value or description on variant when unpacked field is undefined
This commit is contained in:
@@ -295,10 +295,11 @@ productsApp.controller "AdminBulkProductsCtrl", [
|
||||
|
||||
|
||||
$scope.packVariant = (variant) ->
|
||||
match = variant.unit_value_with_description.match(/^([\d\.]+|)( |)(.*)$/)
|
||||
if match
|
||||
variant.unit_value = parseFloat(match[1]) || null
|
||||
variant.unit_description = match[3]
|
||||
if variant.hasOwnProperty("unit_value_with_description")
|
||||
match = variant.unit_value_with_description.match(/^([\d\.]+|)( |)(.*)$/)
|
||||
if match
|
||||
variant.unit_value = parseFloat(match[1]) || null
|
||||
variant.unit_description = match[3]
|
||||
|
||||
|
||||
$scope.productsWithoutDerivedAttributes = ->
|
||||
|
||||
@@ -552,6 +552,11 @@ describe "AdminBulkProductsCtrl", ->
|
||||
unit_description: ''
|
||||
unit_value_with_description: ""
|
||||
|
||||
it "sets nothing when the field is undefined", ->
|
||||
testVariant = {}
|
||||
scope.packVariant(testVariant)
|
||||
expect(testVariant).toEqual {}
|
||||
|
||||
|
||||
describe "filtering products", ->
|
||||
beforeEach ->
|
||||
|
||||
Reference in New Issue
Block a user