From 6b097eb9f8c86726f79c0e06cf93918d9dfd2627 Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 15 May 2013 14:17:36 +0530 Subject: [PATCH] WIP: minor fixes to bulk product update js --- app/assets/javascripts/admin/bulk_product_update.js | 10 +++++----- spec/javascripts/unit/bulk_product_update_spec.js | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/admin/bulk_product_update.js b/app/assets/javascripts/admin/bulk_product_update.js index 2001a4861d..047937f58f 100644 --- a/app/assets/javascripts/admin/bulk_product_update.js +++ b/app/assets/javascripts/admin/bulk_product_update.js @@ -1,4 +1,4 @@ -function AdminBulkProductsCtrl($scope, $http) { +function AdminBulkProductsCtrl($scope, $timeout, $http) { $scope.refreshSuppliers = function(){ $http.get('/enterprises/suppliers.json').success(function(data) { $scope.suppliers = data; @@ -32,11 +32,11 @@ function AdminBulkProductsCtrl($scope, $http) { $scope.displaySuccess(); } else{ - $scope.displayFailure("Product lists do not match"); + $scope.displayFailure("Product lists do not match."); } }) - .error(function(status){ - $scope.displayFailure("Server returned an error: "+status); + .error(function(data,status){ + $scope.displayFailure("Server returned with error status: "+status); }); } @@ -63,7 +63,7 @@ function AdminBulkProductsCtrl($scope, $http) { } $scope.displayFailure = function(failMessage){ - $scope.setMessage($scope.updateStatusMessage,"Updating failed: "+failMessage,{ color: "red" },10000); + $scope.setMessage($scope.updateStatusMessage,"Updating failed. "+failMessage,{ color: "red" },10000); } } diff --git a/spec/javascripts/unit/bulk_product_update_spec.js b/spec/javascripts/unit/bulk_product_update_spec.js index 9c9f313bac..ad10ac8a93 100644 --- a/spec/javascripts/unit/bulk_product_update_spec.js +++ b/spec/javascripts/unit/bulk_product_update_spec.js @@ -139,11 +139,13 @@ describe("Auxillary functions", function(){ describe("AdminBulkProductsCtrl", function(){ ctrl = null; scope = null; + timeout = null; httpBackend = null; supplierController = null; - beforeEach(inject(function($controller,$rootScope,$httpBackend) { + beforeEach(inject(function($controller,$rootScope,$timeout,$httpBackend) { scope = $rootScope.$new(); + timeout = $timeout; ctrl = $controller; httpBackend = $httpBackend; })); @@ -326,12 +328,11 @@ describe("AdminBulkProductsCtrl", function(){ beforeEach(function(){ httpBackend.expectGET('/enterprises/suppliers.json').respond("list of suppliers"); httpBackend.expectGET('/admin/products/bulk_index.json').respond("list of products"); - ctrl('AdminBulkProductsCtrl', { $scope: scope } ); + ctrl('AdminBulkProductsCtrl', { $scope: scope, $timeout: timeout } ); httpBackend.flush(); }); it("submits products to be updated with a http post request to /admin/products/bulk_update", function(){ - spyOn(scope, "displaySuccess"); httpBackend.expectPOST('/admin/products/bulk_update').respond("list of products"); scope.updateProducts("list of products"); httpBackend.flush();