diff --git a/openstack_dashboard/static/app/core/openstack-service-api/glance.service.js b/openstack_dashboard/static/app/core/openstack-service-api/glance.service.js index 99b6b21465..7c0da41a5d 100644 --- a/openstack_dashboard/static/app/core/openstack-service-api/glance.service.js +++ b/openstack_dashboard/static/app/core/openstack-service-api/glance.service.js @@ -169,8 +169,9 @@ onProgress(Math.round(event.loaded / event.total * 100)); } - function onError() { + function onError(error) { toastService.add('error', gettext('Unable to create the image.')); + throw error; } return apiService[method]('/api/glance/images/', image) diff --git a/openstack_dashboard/static/app/core/openstack-service-api/glance.service.spec.js b/openstack_dashboard/static/app/core/openstack-service-api/glance.service.spec.js index 7d4a4f17e0..3e96756801 100644 --- a/openstack_dashboard/static/app/core/openstack-service-api/glance.service.spec.js +++ b/openstack_dashboard/static/app/core/openstack-service-api/glance.service.spec.js @@ -189,9 +189,15 @@ service.createImage.apply(null, [{name: 1}]); + try { + imageQueuedPromise.reject({'data': 'invalid'}); + $rootScope.$apply(); + }catch (exp) { + expect(exp).toBeDefined(); + expect(exp.data).toEqual('invalid'); + } + expect(apiService.put).toHaveBeenCalledWith('/api/glance/images/', {name: 1}); - imageQueuedPromise.reject(); - $rootScope.$apply(); expect(toastService.add).toHaveBeenCalledWith('error', "Unable to create the image."); }); @@ -228,8 +234,13 @@ }); it('second call is not started if the initial image creation fails', function() { - imageQueuedPromise.reject(); - $rootScope.$apply(); + try { + imageQueuedPromise.reject({'data': 'invalid'}); + $rootScope.$apply(); + }catch (exp) { + expect(exp).toBeDefined(); + expect(exp.data).toEqual('invalid'); + } expect(apiService.put.calls.count()).toBe(1); });