Test fetching enterprises

This commit is contained in:
Rohan Mitchell
2012-12-13 16:24:59 +11:00
parent 8d8c2f04d8
commit 19e55428b8
2 changed files with 25 additions and 0 deletions

View File

@@ -137,6 +137,7 @@ angular.module('order_cycle', ['ngResource']).
{'index': { method: 'GET', isArray: true}});
return {
Enterprise: Enterprise,
enterprises: {},
index: function() {

View File

@@ -80,6 +80,30 @@ describe 'OrderCycle controllers', ->
describe 'OrderCycle services', ->
describe 'Enterprise service', ->
$httpBackend = null
Enterprise = null
beforeEach ->
module 'order_cycle'
inject ($injector, _$httpBackend_)->
Enterprise = $injector.get('Enterprise')
$httpBackend = _$httpBackend_
$httpBackend.whenGET('/admin/enterprises.json').respond [
{id: 1, name: 'One'}
{id: 2, name: 'Two'}
{id: 3, name: 'Three'}
]
it 'loads enterprises as a hash', ->
enterprises = Enterprise.index()
$httpBackend.flush()
expect(enterprises).toEqual
1: new Enterprise.Enterprise({id: 1, name: 'One'})
2: new Enterprise.Enterprise({id: 2, name: 'Two'})
3: new Enterprise.Enterprise({id: 3, name: 'Three'})
describe 'OrderCycle service', ->
OrderCycle = null
$httpBackend = null