Removing a supplier exchange removes variants from distribution

This commit is contained in:
Rohan Mitchell
2013-09-30 09:46:39 +10:00
parent 32204076bd
commit 1d4198d402
4 changed files with 58 additions and 3 deletions

View File

@@ -21,6 +21,7 @@ describe 'OrderCycle controllers', ->
toggleProducts: jasmine.createSpy('toggleProducts')
addSupplier: jasmine.createSpy('addSupplier')
addDistributor: jasmine.createSpy('addDistributor')
removeExchange: jasmine.createSpy('removeExchange')
addCoordinatorFee: jasmine.createSpy('addCoordinatorFee')
removeCoordinatorFee: jasmine.createSpy('removeCoordinatorFee')
addExchangeFee: jasmine.createSpy('addExchangeFee')
@@ -102,6 +103,11 @@ describe 'OrderCycle controllers', ->
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addDistributor).toHaveBeenCalledWith('new distributor id')
it 'Removes order cycle exchanges', ->
scope.removeExchange(event, 'exchange')
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.removeExchange).toHaveBeenCalledWith('exchange')
it 'Adds coordinator fees', ->
scope.addCoordinatorFee(event)
expect(event.preventDefault).toHaveBeenCalled()
@@ -155,6 +161,7 @@ describe 'OrderCycle controllers', ->
toggleProducts: jasmine.createSpy('toggleProducts')
addSupplier: jasmine.createSpy('addSupplier')
addDistributor: jasmine.createSpy('addDistributor')
removeExchange: jasmine.createSpy('removeExchange')
addCoordinatorFee: jasmine.createSpy('addCoordinatorFee')
removeCoordinatorFee: jasmine.createSpy('removeCoordinatorFee')
addExchangeFee: jasmine.createSpy('addExchangeFee')
@@ -235,6 +242,11 @@ describe 'OrderCycle controllers', ->
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addDistributor).toHaveBeenCalledWith('new distributor id')
it 'Removes order cycle exchanges', ->
scope.removeExchange(event, 'exchange')
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.removeExchange).toHaveBeenCalledWith('exchange')
it 'Adds coordinator fees', ->
scope.addCoordinatorFee(event)
expect(event.preventDefault).toHaveBeenCalled()
@@ -421,6 +433,32 @@ describe 'OrderCycle services', ->
{enterprise_id: '123', active: true, variants: {}, enterprise_fees: []}
]
describe 'removing exchanges', ->
it 'removes incoming exchanges', ->
exchange = {enterprise_id: '123', active: true, variants: {}, enterprise_fees: []}
OrderCycle.order_cycle.incoming_exchanges = [exchange]
OrderCycle.removeExchange(exchange)
expect(OrderCycle.order_cycle.incoming_exchanges).toEqual []
it 'removes outgoing exchanges', ->
exchange = {enterprise_id: '123', active: true, variants: {}, enterprise_fees: []}
OrderCycle.order_cycle.outgoing_exchanges = [exchange]
OrderCycle.removeExchange(exchange)
expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual []
it 'removes distribution of all exchange variants', ->
spyOn(OrderCycle, 'removeDistributionOfVariant')
exchange =
enterprise_id: '123'
active: true
variants: {1: true, 2: false, 3: true}
enterprise_fees: []
OrderCycle.order_cycle.incoming_exchanges = [exchange]
OrderCycle.removeExchange(exchange)
expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('1')
expect(OrderCycle.removeDistributionOfVariant).not.toHaveBeenCalledWith('2')
expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('3')
it 'adds coordinator fees', ->
OrderCycle.addCoordinatorFee()
expect(OrderCycle.order_cycle.coordinator_fees).toEqual [{}]