Display only coordinator fees belonging to the selected coordinator

This commit is contained in:
Rohan Mitchell
2013-07-30 10:19:38 +10:00
parent 43474d6408
commit ae0f82b479
3 changed files with 32 additions and 5 deletions

View File

@@ -27,6 +27,7 @@ describe 'OrderCycle controllers', ->
totalVariants: jasmine.createSpy('totalVariants').andReturn('variants total')
EnterpriseFee =
index: jasmine.createSpy('index').andReturn('enterprise fees list')
forEnterprise: jasmine.createSpy('forEnterprise').andReturn('enterprise fees for enterprise')
module('order_cycle')
inject ($controller) ->
@@ -66,6 +67,10 @@ describe 'OrderCycle controllers', ->
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.toggleProducts).toHaveBeenCalledWith('exchange')
it 'Delegates enterpriseFeesForEnterprise to EnterpriseFee', ->
scope.enterpriseFeesForEnterprise('123')
expect(EnterpriseFee.forEnterprise).toHaveBeenCalledWith(123)
it 'Adds order cycle suppliers', ->
scope.new_supplier_id = 'new supplier id'
scope.addSupplier(event)
@@ -113,6 +118,7 @@ describe 'OrderCycle controllers', ->
totalVariants: jasmine.createSpy('totalVariants').andReturn('variants total')
EnterpriseFee =
index: jasmine.createSpy('index').andReturn('enterprise fees list')
forEnterprise: jasmine.createSpy('forEnterprise').andReturn('enterprise fees for enterprise')
module('order_cycle')
inject ($controller) ->
@@ -151,6 +157,10 @@ describe 'OrderCycle controllers', ->
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.toggleProducts).toHaveBeenCalledWith('exchange')
it 'Delegates enterpriseFeesForEnterprise to EnterpriseFee', ->
scope.enterpriseFeesForEnterprise('123')
expect(EnterpriseFee.forEnterprise).toHaveBeenCalledWith(123)
it 'Adds order cycle suppliers', ->
scope.new_supplier_id = 'new supplier id'
scope.addSupplier(event)
@@ -218,16 +228,24 @@ describe 'OrderCycle services', ->
EnterpriseFee = $injector.get('EnterpriseFee')
$httpBackend = _$httpBackend_
$httpBackend.whenGET('/admin/enterprise_fees.json').respond [
{id: 1, name: "Yayfee"}
{id: 2, name: "FeeTwo"}
{id: 1, name: "Yayfee", enterprise_id: 1}
{id: 2, name: "FeeTwo", enterprise_id: 2}
]
it 'loads enterprise fees', ->
enterprise_fees = EnterpriseFee.index()
$httpBackend.flush()
expect(enterprise_fees).toEqual [
new EnterpriseFee.EnterpriseFee({id: 1, name: "Yayfee"})
new EnterpriseFee.EnterpriseFee({id: 2, name: "FeeTwo"})
new EnterpriseFee.EnterpriseFee({id: 1, name: "Yayfee", enterprise_id: 1})
new EnterpriseFee.EnterpriseFee({id: 2, name: "FeeTwo", enterprise_id: 2})
]
it 'returns enterprise fees for an enterprise', ->
all_enterprise_fees = EnterpriseFee.index()
$httpBackend.flush()
enterprise_fees = EnterpriseFee.forEnterprise(1)
expect(enterprise_fees).toEqual [
new EnterpriseFee.EnterpriseFee({id: 1, name: "Yayfee", enterprise_id: 1})
]