mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Load enterprise fees in controllers
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
angular.module('order_cycle', ['ngResource'])
|
||||
.controller('AdminCreateOrderCycleCtrl', ['$scope', 'OrderCycle', 'Enterprise', ($scope, OrderCycle, Enterprise) ->
|
||||
.controller('AdminCreateOrderCycleCtrl', ['$scope', 'OrderCycle', 'Enterprise', 'EnterpriseFee', ($scope, OrderCycle, Enterprise, EnterpriseFee) ->
|
||||
$scope.enterprises = Enterprise.index()
|
||||
$scope.supplied_products = Enterprise.supplied_products
|
||||
$scope.enterprise_fees = EnterpriseFee.index()
|
||||
|
||||
$scope.order_cycle = OrderCycle.order_cycle
|
||||
|
||||
@@ -36,9 +37,10 @@ angular.module('order_cycle', ['ngResource'])
|
||||
OrderCycle.create()
|
||||
])
|
||||
|
||||
.controller('AdminEditOrderCycleCtrl', ['$scope', '$location', 'OrderCycle', 'Enterprise', ($scope, $location, OrderCycle, Enterprise) ->
|
||||
.controller('AdminEditOrderCycleCtrl', ['$scope', '$location', 'OrderCycle', 'Enterprise', 'EnterpriseFee', ($scope, $location, OrderCycle, Enterprise, EnterpriseFee) ->
|
||||
$scope.enterprises = Enterprise.index()
|
||||
$scope.supplied_products = Enterprise.supplied_products
|
||||
$scope.enterprise_fees = EnterpriseFee.index()
|
||||
|
||||
order_cycle_id = $location.absUrl().match(/\/admin\/order_cycles\/(\d+)/)[1]
|
||||
$scope.order_cycle = OrderCycle.load(order_cycle_id)
|
||||
|
||||
@@ -58,5 +58,9 @@
|
||||
%h2 Debug information
|
||||
|
||||
%pre order_cycle = {{ order_cycle | json }}
|
||||
%hr/
|
||||
%pre enterprises = {{ enterprises | json }}
|
||||
%hr/
|
||||
%pre enterprise_fees = {{ enterprise_fees | json }}
|
||||
%hr/
|
||||
%pre supplied_products = {{ supplied_products | json }}
|
||||
|
||||
@@ -6,6 +6,7 @@ describe 'OrderCycle controllers', ->
|
||||
event = null
|
||||
OrderCycle = null
|
||||
Enterprise = null
|
||||
EnterpriseFee = null
|
||||
|
||||
beforeEach ->
|
||||
scope = {}
|
||||
@@ -24,10 +25,12 @@ describe 'OrderCycle controllers', ->
|
||||
index: jasmine.createSpy('index').andReturn('enterprises list')
|
||||
supplied_products: 'supplied products'
|
||||
totalVariants: jasmine.createSpy('totalVariants').andReturn('variants total')
|
||||
EnterpriseFee =
|
||||
index: jasmine.createSpy('index').andReturn('enterprise fees list')
|
||||
|
||||
module('order_cycle')
|
||||
inject ($controller) ->
|
||||
ctrl = $controller 'AdminCreateOrderCycleCtrl', {$scope: scope, OrderCycle: OrderCycle, Enterprise: Enterprise}
|
||||
ctrl = $controller 'AdminCreateOrderCycleCtrl', {$scope: scope, OrderCycle: OrderCycle, Enterprise: Enterprise, EnterpriseFee: EnterpriseFee}
|
||||
|
||||
|
||||
it 'Loads enterprises and supplied products', ->
|
||||
@@ -35,6 +38,10 @@ describe 'OrderCycle controllers', ->
|
||||
expect(scope.enterprises).toEqual('enterprises list')
|
||||
expect(scope.supplied_products).toEqual('supplied products')
|
||||
|
||||
it 'Loads enterprise fees', ->
|
||||
expect(EnterpriseFee.index).toHaveBeenCalled()
|
||||
expect(scope.enterprise_fees).toEqual('enterprise fees list')
|
||||
|
||||
it 'Loads order cycles', ->
|
||||
expect(scope.order_cycle).toEqual('my order cycle')
|
||||
|
||||
@@ -82,6 +89,7 @@ describe 'OrderCycle controllers', ->
|
||||
location = null
|
||||
OrderCycle = null
|
||||
Enterprise = null
|
||||
EnterpriseFee = null
|
||||
|
||||
beforeEach ->
|
||||
scope = {}
|
||||
@@ -103,16 +111,22 @@ describe 'OrderCycle controllers', ->
|
||||
index: jasmine.createSpy('index').andReturn('enterprises list')
|
||||
supplied_products: 'supplied products'
|
||||
totalVariants: jasmine.createSpy('totalVariants').andReturn('variants total')
|
||||
EnterpriseFee =
|
||||
index: jasmine.createSpy('index').andReturn('enterprise fees list')
|
||||
|
||||
module('order_cycle')
|
||||
inject ($controller) ->
|
||||
ctrl = $controller 'AdminEditOrderCycleCtrl', {$scope: scope, $location: location, OrderCycle: OrderCycle, Enterprise: Enterprise}
|
||||
ctrl = $controller 'AdminEditOrderCycleCtrl', {$scope: scope, $location: location, OrderCycle: OrderCycle, Enterprise: Enterprise, EnterpriseFee: EnterpriseFee}
|
||||
|
||||
it 'Loads enterprises and supplied products', ->
|
||||
expect(Enterprise.index).toHaveBeenCalled()
|
||||
expect(scope.enterprises).toEqual('enterprises list')
|
||||
expect(scope.supplied_products).toEqual('supplied products')
|
||||
|
||||
it 'Loads enterprise fees', ->
|
||||
expect(EnterpriseFee.index).toHaveBeenCalled()
|
||||
expect(scope.enterprise_fees).toEqual('enterprise fees list')
|
||||
|
||||
it 'Loads order cycles', ->
|
||||
expect(OrderCycle.load).toHaveBeenCalledWith('27')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user