Only show variants for distribution that are supplied to the order cycle

This commit is contained in:
Rohan Mitchell
2013-01-18 11:52:01 +11:00
parent 1a0ef85030
commit 0a2ce30bb6
3 changed files with 31 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ describe 'OrderCycle controllers', ->
order_cycle: 'my order cycle'
exchangeSelectedVariants: jasmine.createSpy('exchangeSelectedVariants').andReturn('variants selected')
productSuppliedToOrderCycle: jasmine.createSpy('productSuppliedToOrderCycle').andReturn('product supplied')
variantSuppliedToOrderCycle: jasmine.createSpy('variantSuppliedToOrderCycle').andReturn('variant supplied')
toggleProducts: jasmine.createSpy('toggleProducts')
addSupplier: jasmine.createSpy('addSupplier')
addDistributor: jasmine.createSpy('addDistributor')
@@ -49,6 +50,10 @@ describe 'OrderCycle controllers', ->
expect(scope.productSuppliedToOrderCycle('product')).toEqual('product supplied')
expect(OrderCycle.productSuppliedToOrderCycle).toHaveBeenCalledWith('product')
it 'Delegates variantSuppliedToOrderCycle to OrderCycle', ->
expect(scope.variantSuppliedToOrderCycle('variant')).toEqual('variant supplied')
expect(OrderCycle.variantSuppliedToOrderCycle).toHaveBeenCalledWith('variant')
it 'Delegates toggleProducts to OrderCycle', ->
scope.toggleProducts(event, 'exchange')
expect(event.preventDefault).toHaveBeenCalled()
@@ -89,6 +94,7 @@ describe 'OrderCycle controllers', ->
load: jasmine.createSpy('load')
exchangeSelectedVariants: jasmine.createSpy('exchangeSelectedVariants').andReturn('variants selected')
productSuppliedToOrderCycle: jasmine.createSpy('productSuppliedToOrderCycle').andReturn('product supplied')
variantSuppliedToOrderCycle: jasmine.createSpy('variantSuppliedToOrderCycle').andReturn('variant supplied')
toggleProducts: jasmine.createSpy('toggleProducts')
addSupplier: jasmine.createSpy('addSupplier')
addDistributor: jasmine.createSpy('addDistributor')
@@ -122,6 +128,10 @@ describe 'OrderCycle controllers', ->
expect(scope.productSuppliedToOrderCycle('product')).toEqual('product supplied')
expect(OrderCycle.productSuppliedToOrderCycle).toHaveBeenCalledWith('product')
it 'Delegates variantSuppliedToOrderCycle to OrderCycle', ->
expect(scope.variantSuppliedToOrderCycle('variant')).toEqual('variant supplied')
expect(OrderCycle.variantSuppliedToOrderCycle).toHaveBeenCalledWith('variant')
it 'Delegates toggleProducts to OrderCycle', ->
scope.toggleProducts(event, 'exchange')
expect(event.preventDefault).toHaveBeenCalled()
@@ -300,6 +310,17 @@ describe 'OrderCycle services', ->
expect(OrderCycle.productSuppliedToOrderCycle(product_variant_absent)).toBeFalsy()
describe 'checking whether a variant is supplied to the order cycle', ->
beforeEach ->
spyOn(OrderCycle, 'incomingExchangesVariants').andReturn([1, 3])
it 'returns true for variants that are supplied', ->
expect(OrderCycle.variantSuppliedToOrderCycle({id: 1})).toBeTruthy()
it 'returns false for variants that are not supplied', ->
expect(OrderCycle.variantSuppliedToOrderCycle({id: 999})).toBeFalsy()
describe 'loading an order cycle', ->
beforeEach ->
OrderCycle.load('123')