mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-09 03:20:21 +00:00
Merging master into all the things
This commit is contained in:
@@ -12,5 +12,5 @@ describe "enterprise relationships", ->
|
||||
EnterpriseRelationships = _EnterpriseRelationships_
|
||||
|
||||
it "presents permission names", ->
|
||||
expect(EnterpriseRelationships.permission_presentation("add_to_order_cycle")).toEqual "can add to order cycle"
|
||||
expect(EnterpriseRelationships.permission_presentation("manage_products")).toEqual "can manage the products of"
|
||||
expect(EnterpriseRelationships.permission_presentation("add_to_order_cycle")).toEqual "to add to order cycle"
|
||||
expect(EnterpriseRelationships.permission_presentation("manage_products")).toEqual "to manage products"
|
||||
|
||||
@@ -8,18 +8,21 @@ describe "Hubs service", ->
|
||||
active: false
|
||||
orders_close_at: new Date()
|
||||
is_distributor: true
|
||||
has_shopfront: true
|
||||
}
|
||||
{
|
||||
id: 3
|
||||
active: false
|
||||
orders_close_at: new Date()
|
||||
is_distributor: true
|
||||
has_shopfront: true
|
||||
}
|
||||
{
|
||||
id: 1
|
||||
active: true
|
||||
orders_close_at: new Date()
|
||||
is_distributor: true
|
||||
has_shopfront: true
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -516,30 +516,44 @@ describe 'OrderCycle services', ->
|
||||
]
|
||||
|
||||
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 []
|
||||
exchange = null
|
||||
|
||||
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', ->
|
||||
beforeEach ->
|
||||
spyOn(OrderCycle, 'removeDistributionOfVariant')
|
||||
exchange =
|
||||
enterprise_id: '123'
|
||||
active: true
|
||||
incoming: false
|
||||
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')
|
||||
|
||||
describe "removing incoming exchanges", ->
|
||||
beforeEach ->
|
||||
exchange.incoming = true
|
||||
OrderCycle.order_cycle.incoming_exchanges = [exchange]
|
||||
|
||||
it 'removes the exchange', ->
|
||||
OrderCycle.removeExchange(exchange)
|
||||
expect(OrderCycle.order_cycle.incoming_exchanges).toEqual []
|
||||
|
||||
it 'removes distribution of all exchange variants', ->
|
||||
OrderCycle.removeExchange(exchange)
|
||||
expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('1')
|
||||
expect(OrderCycle.removeDistributionOfVariant).not.toHaveBeenCalledWith('2')
|
||||
expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('3')
|
||||
|
||||
describe "removing outgoing exchanges", ->
|
||||
beforeEach ->
|
||||
exchange.incoming = false
|
||||
OrderCycle.order_cycle.outgoing_exchanges = [exchange]
|
||||
|
||||
it 'removes the exchange', ->
|
||||
OrderCycle.removeExchange(exchange)
|
||||
expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual []
|
||||
|
||||
it "does not remove distribution of any variants", ->
|
||||
OrderCycle.removeExchange(exchange)
|
||||
expect(OrderCycle.removeDistributionOfVariant).not.toHaveBeenCalled()
|
||||
|
||||
it 'adds coordinator fees', ->
|
||||
OrderCycle.addCoordinatorFee()
|
||||
|
||||
Reference in New Issue
Block a user