mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
When a variant is removed from supply to an order cycle, remove it from distribution also
This commit is contained in:
@@ -25,6 +25,7 @@ describe 'OrderCycle controllers', ->
|
||||
removeCoordinatorFee: jasmine.createSpy('removeCoordinatorFee')
|
||||
addExchangeFee: jasmine.createSpy('addExchangeFee')
|
||||
removeExchangeFee: jasmine.createSpy('removeExchangeFee')
|
||||
removeDistributionOfVariant: jasmine.createSpy('removeDistributionOfVariant')
|
||||
create: jasmine.createSpy('create')
|
||||
Enterprise =
|
||||
index: jasmine.createSpy('index').andReturn('enterprises list')
|
||||
@@ -121,6 +122,10 @@ describe 'OrderCycle controllers', ->
|
||||
expect(event.preventDefault).toHaveBeenCalled()
|
||||
expect(OrderCycle.removeExchangeFee).toHaveBeenCalledWith('exchange', 0)
|
||||
|
||||
it 'Removes distribution of a variant', ->
|
||||
scope.removeDistributionOfVariant('variant')
|
||||
expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('variant')
|
||||
|
||||
it 'Submits the order cycle via OrderCycle create', ->
|
||||
scope.submit()
|
||||
expect(OrderCycle.create).toHaveBeenCalled()
|
||||
@@ -154,6 +159,7 @@ describe 'OrderCycle controllers', ->
|
||||
removeCoordinatorFee: jasmine.createSpy('removeCoordinatorFee')
|
||||
addExchangeFee: jasmine.createSpy('addExchangeFee')
|
||||
removeExchangeFee: jasmine.createSpy('removeExchangeFee')
|
||||
removeDistributionOfVariant: jasmine.createSpy('removeDistributionOfVariant')
|
||||
update: jasmine.createSpy('update')
|
||||
Enterprise =
|
||||
index: jasmine.createSpy('index').andReturn('enterprises list')
|
||||
@@ -249,6 +255,10 @@ describe 'OrderCycle controllers', ->
|
||||
expect(event.preventDefault).toHaveBeenCalled()
|
||||
expect(OrderCycle.removeExchangeFee).toHaveBeenCalledWith('exchange', 0)
|
||||
|
||||
it 'Removes distribution of a variant', ->
|
||||
scope.removeDistributionOfVariant('variant')
|
||||
expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('variant')
|
||||
|
||||
it 'Submits the order cycle via OrderCycle update', ->
|
||||
scope.submit()
|
||||
expect(OrderCycle.update).toHaveBeenCalled()
|
||||
@@ -514,6 +524,18 @@ describe 'OrderCycle services', ->
|
||||
expect(OrderCycle.variantSuppliedToOrderCycle({id: 999})).toBeFalsy()
|
||||
|
||||
|
||||
describe 'remove all distribution of a variant', ->
|
||||
it 'removes the variant from every outgoing exchange', ->
|
||||
OrderCycle.order_cycle.outgoing_exchanges = [
|
||||
{variants: {123: true, 234: true}}
|
||||
{variants: {123: true, 333: true}}
|
||||
]
|
||||
OrderCycle.removeDistributionOfVariant('123')
|
||||
expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual [
|
||||
{variants: {123: false, 234: true}}
|
||||
{variants: {123: false, 333: true}}
|
||||
]
|
||||
|
||||
describe 'loading an order cycle', ->
|
||||
beforeEach ->
|
||||
OrderCycle.load('123')
|
||||
|
||||
Reference in New Issue
Block a user