mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-17 00:07:24 +00:00
Enterprise service splits enterprises into hubs and producers
This commit is contained in:
@@ -333,18 +333,18 @@ describe 'OrderCycle services', ->
|
||||
Enterprise = $injector.get('Enterprise')
|
||||
$httpBackend = _$httpBackend_
|
||||
$httpBackend.whenGET('/admin/enterprises/for_order_cycle.json?').respond [
|
||||
{id: 1, name: 'One', supplied_products: [1, 2]}
|
||||
{id: 1, name: 'One', supplied_products: [1, 2], is_primary_producer: true}
|
||||
{id: 2, name: 'Two', supplied_products: [3, 4]}
|
||||
{id: 3, name: 'Three', supplied_products: [5, 6]}
|
||||
{id: 3, name: 'Three', supplied_products: [5, 6], sells: 'any'}
|
||||
]
|
||||
|
||||
it 'loads enterprises as a hash', ->
|
||||
enterprises = Enterprise.index()
|
||||
$httpBackend.flush()
|
||||
expect(enterprises).toEqual
|
||||
1: new Enterprise.Enterprise({id: 1, name: 'One', supplied_products: [1, 2]})
|
||||
1: new Enterprise.Enterprise({id: 1, name: 'One', supplied_products: [1, 2], is_primary_producer: true})
|
||||
2: new Enterprise.Enterprise({id: 2, name: 'Two', supplied_products: [3, 4]})
|
||||
3: new Enterprise.Enterprise({id: 3, name: 'Three', supplied_products: [5, 6]})
|
||||
3: new Enterprise.Enterprise({id: 3, name: 'Three', supplied_products: [5, 6], sells: 'any'})
|
||||
|
||||
it 'reports its loadedness', ->
|
||||
expect(Enterprise.loaded).toBe(false)
|
||||
@@ -352,6 +352,16 @@ describe 'OrderCycle services', ->
|
||||
$httpBackend.flush()
|
||||
expect(Enterprise.loaded).toBe(true)
|
||||
|
||||
it 'loads producers as an array', ->
|
||||
Enterprise.index()
|
||||
$httpBackend.flush()
|
||||
expect(Enterprise.producer_enterprises).toEqual [new Enterprise.Enterprise({id: 1, name: 'One', supplied_products: [1, 2], is_primary_producer: true})]
|
||||
|
||||
it 'loads hubs as an array', ->
|
||||
Enterprise.index()
|
||||
$httpBackend.flush()
|
||||
expect(Enterprise.hub_enterprises).toEqual [new Enterprise.Enterprise({id: 3, name: 'Three', supplied_products: [5, 6], sells: 'any'})]
|
||||
|
||||
it 'collates all supplied products', ->
|
||||
enterprises = Enterprise.index()
|
||||
$httpBackend.flush()
|
||||
|
||||
Reference in New Issue
Block a user