Order cycle simple create controller uses 'new' method on OC service to initialise

This commit is contained in:
Rob Harrington
2015-03-27 11:29:02 +11:00
parent 4d14acb64d
commit aa170ef5f6
2 changed files with 9 additions and 4 deletions

View File

@@ -1,8 +1,9 @@
angular.module('admin.order_cycles').controller "AdminSimpleCreateOrderCycleCtrl", ($scope, OrderCycle, Enterprise, EnterpriseFee, ocInstance) ->
# TODO: make this a get method, which only fetches one enterprise
$scope.enterprises = Enterprise.index {coordinator_id: ocInstance.coordinator_id}, (enterprises) =>
$scope.init(enterprises)
$scope.enterprise_fees = EnterpriseFee.index()
$scope.order_cycle = OrderCycle.order_cycle
$scope.order_cycle = OrderCycle.new({coordinator_id: ocInstance.coordinator_id})
$scope.init = (enterprises) ->
enterprise = enterprises[Object.keys(enterprises)[0]]

View File

@@ -9,14 +9,18 @@ describe "AdminSimpleCreateOrderCycleCtrl", ->
beforeEach ->
scope = {}
order_cycle =
coordinator_id: 123
incoming_exchanges: [incoming_exchange]
outgoing_exchanges: [outgoing_exchange]
OrderCycle =
order_cycle:
incoming_exchanges: [incoming_exchange]
outgoing_exchanges: [outgoing_exchange]
order_cycle: order_cycle
addSupplier: jasmine.createSpy()
addDistributor: jasmine.createSpy()
setExchangeVariants: jasmine.createSpy()
new: jasmine.createSpy().andReturn order_cycle
Enterprise =
get: jasmine.createSpy().andReturn {id: 123}
index: jasmine.createSpy()
suppliedVariants: jasmine.createSpy().andReturn('supplied variants')
EnterpriseFee =