mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-23 05:28:53 +00:00
Do not error if order cycle loads before enterprises
This commit is contained in:
@@ -328,8 +328,9 @@ angular.module('order_cycle', ['ngResource'])
|
||||
totalVariants: (enterprise) ->
|
||||
numVariants = 0
|
||||
|
||||
counts = for product in enterprise.supplied_products
|
||||
numVariants += if product.variants.length == 0 then 1 else product.variants.length
|
||||
if enterprise
|
||||
counts = for product in enterprise.supplied_products
|
||||
numVariants += if product.variants.length == 0 then 1 else product.variants.length
|
||||
|
||||
numVariants
|
||||
}])
|
||||
|
||||
@@ -342,6 +342,8 @@ describe 'OrderCycle services', ->
|
||||
|
||||
expect(Enterprise.totalVariants(enterprise)).toEqual(5)
|
||||
|
||||
it 'returns zero when enterprise is null', ->
|
||||
expect(Enterprise.totalVariants(null)).toEqual(0)
|
||||
|
||||
describe 'EnterpriseFee service', ->
|
||||
$httpBackend = null
|
||||
|
||||
Reference in New Issue
Block a user