Fix failing bulk specs

This commit is contained in:
Rob H
2014-08-24 10:08:50 +10:00
parent 8d570286a1
commit 800eecea33
2 changed files with 9 additions and 6 deletions

View File

@@ -2,7 +2,9 @@ describe "AdminOrderMgmtCtrl", ->
ctrl = scope = httpBackend = VariantUnitManager = null
beforeEach ->
module "ofn.admin"
module "ofn.admin", ($provide) ->
$provide.value 'SpreeApiKey', 'API_KEY'
return
beforeEach inject(($controller, $rootScope, $httpBackend, _VariantUnitManager_) ->
scope = $rootScope.$new()
ctrl = $controller
@@ -18,7 +20,7 @@ describe "AdminOrderMgmtCtrl", ->
returnedSuppliers = ["list of suppliers"]
returnedDistributors = ["list of distributors"]
returnedOrderCycles = [ "oc1", "oc2", "oc3" ]
httpBackend.expectGET("/api/users/authorise_api?token=api_key").respond success: "Use of API Authorised"
httpBackend.expectGET("/api/users/authorise_api?token=API_KEY").respond success: "Use of API Authorised"
httpBackend.expectGET("/api/enterprises/accessible?template=bulk_index&q[is_primary_producer_eq]=true").respond returnedSuppliers
httpBackend.expectGET("/api/enterprises/accessible?template=bulk_index&q[is_distributor_eq]=true").respond returnedDistributors
httpBackend.expectGET("/api/order_cycles/accessible").respond returnedOrderCycles
@@ -27,7 +29,7 @@ describe "AdminOrderMgmtCtrl", ->
#spyOn(returnedSuppliers, "unshift")
#spyOn(returnedDistributors, "unshift")
#spyOn(returnedOrderCycles, "unshift")
scope.initialise "api_key"
scope.initialise()
httpBackend.flush()
expect(scope.suppliers).toEqual [{ id : '0', name : 'All' }, 'list of suppliers']

View File

@@ -165,7 +165,7 @@ describe "filtering products for submission to database", ->
variant_unit: 'weight'
variant_unit_scale: 1
]
# TODO Not an exhaustive test, is there a better way to do this?
it "only returns the properties of products which ought to be updated", ->
available_on = new Date()
@@ -238,6 +238,7 @@ describe "AdminProductEditCtrl", ->
module ($provide)->
$provide.value "producers", []
$provide.value "taxons", []
$provide.value 'SpreeApiKey', 'API_KEY'
null
beforeEach inject((_$controller_, _$timeout_, $rootScope, _$httpBackend_, _DirtyProducts_) ->
@@ -252,9 +253,9 @@ describe "AdminProductEditCtrl", ->
describe "loading data upon initialisation", ->
it "gets a list of producers and then resets products with a list of data", ->
$httpBackend.expectGET("/api/users/authorise_api?token=api_key").respond success: "Use of API Authorised"
$httpBackend.expectGET("/api/users/authorise_api?token=API_KEY").respond success: "Use of API Authorised"
spyOn($scope, "fetchProducts").andReturn "nothing"
$scope.initialise "api_key"
$scope.initialise()
$httpBackend.flush()
expect($scope.fetchProducts.calls.length).toEqual 1
expect($scope.spree_api_key_ok).toEqual true