Initialise product.variant_names

Not initialising `product.variant_names` causes it to become the string
"undefinedVariant1Variant2" while it should just be "Variant1Variant2".

This mistake did not matter when `variant_names` was just used to search
for a sub-string. A recent change to search only for the beginning of a
word, caused this to fail.

See: https://github.com/openfoodfoundation/openfoodnetwork/pull/1545
This commit is contained in:
Maikel Linke
2017-06-14 16:28:55 +10:00
parent 1196cd7df4
commit a42799dff4
2 changed files with 7 additions and 0 deletions

View File

@@ -82,6 +82,12 @@ describe 'Products service', ->
$httpBackend.flush()
expect(Products.products[0].variants[0]).toBe Variants.variants[1]
it "stores variant names", ->
product.variants = [{id: 1, name_to_display: "one"}, {id: 2, name_to_display: "two"}]
$httpBackend.expectGET("/shop/products").respond([product])
$httpBackend.flush()
expect(Products.products[0].variant_names).toEqual "onetwo"
it "sets primaryImageOrMissing when no images are provided", ->
$httpBackend.expectGET("/shop/products").respond([product])
$httpBackend.flush()