Do not error if order cycle loads before enterprises

This commit is contained in:
Rohan Mitchell
2013-10-24 13:40:27 +11:00
parent e265b406d6
commit 5c9c96e174
2 changed files with 5 additions and 2 deletions

View File

@@ -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
}])

View File

@@ -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