From 800eecea33b26b0e83c2ade943b6c2c10dc96122 Mon Sep 17 00:00:00 2001 From: Rob H Date: Sun, 24 Aug 2014 10:08:50 +1000 Subject: [PATCH] Fix failing bulk specs --- .../javascripts/unit/bulk_order_management_spec.js.coffee | 8 +++++--- spec/javascripts/unit/bulk_product_update_spec.js.coffee | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/spec/javascripts/unit/bulk_order_management_spec.js.coffee b/spec/javascripts/unit/bulk_order_management_spec.js.coffee index 80884b855d..35b9e13d61 100644 --- a/spec/javascripts/unit/bulk_order_management_spec.js.coffee +++ b/spec/javascripts/unit/bulk_order_management_spec.js.coffee @@ -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'] diff --git a/spec/javascripts/unit/bulk_product_update_spec.js.coffee b/spec/javascripts/unit/bulk_product_update_spec.js.coffee index b9081a1882..649ab99f52 100644 --- a/spec/javascripts/unit/bulk_product_update_spec.js.coffee +++ b/spec/javascripts/unit/bulk_product_update_spec.js.coffee @@ -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