summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-15 12:46:38 +0000
committerGerrit Code Review <review@openstack.org>2017-06-15 12:46:38 +0000
commitda8513debb9a4ff9f14c45d92653166d49099ac9 (patch)
tree5ad347c01002a78c74f70f937b824ad010a0a3f1
parent6cca25d274b0660014f1e1866c1f91c921453b12 (diff)
parentfe27a478174c87cfa250bdc49851d9fc0972282d (diff)
Merge "Reject result when createImage call has error" into stable/ocata
-rw-r--r--openstack_dashboard/static/app/core/openstack-service-api/glance.service.js3
-rw-r--r--openstack_dashboard/static/app/core/openstack-service-api/glance.service.spec.js19
2 files changed, 17 insertions, 5 deletions
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 99b6b21..7c0da41 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 @@
169 onProgress(Math.round(event.loaded / event.total * 100)); 169 onProgress(Math.round(event.loaded / event.total * 100));
170 } 170 }
171 171
172 function onError() { 172 function onError(error) {
173 toastService.add('error', gettext('Unable to create the image.')); 173 toastService.add('error', gettext('Unable to create the image.'));
174 throw error;
174 } 175 }
175 176
176 return apiService[method]('/api/glance/images/', image) 177 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 7d4a4f1..3e96756 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 @@
189 189
190 service.createImage.apply(null, [{name: 1}]); 190 service.createImage.apply(null, [{name: 1}]);
191 191
192 try {
193 imageQueuedPromise.reject({'data': 'invalid'});
194 $rootScope.$apply();
195 }catch (exp) {
196 expect(exp).toBeDefined();
197 expect(exp.data).toEqual('invalid');
198 }
199
192 expect(apiService.put).toHaveBeenCalledWith('/api/glance/images/', {name: 1}); 200 expect(apiService.put).toHaveBeenCalledWith('/api/glance/images/', {name: 1});
193 imageQueuedPromise.reject();
194 $rootScope.$apply();
195 expect(toastService.add).toHaveBeenCalledWith('error', "Unable to create the image."); 201 expect(toastService.add).toHaveBeenCalledWith('error', "Unable to create the image.");
196 }); 202 });
197 203
@@ -228,8 +234,13 @@
228 }); 234 });
229 235
230 it('second call is not started if the initial image creation fails', function() { 236 it('second call is not started if the initial image creation fails', function() {
231 imageQueuedPromise.reject(); 237 try {
232 $rootScope.$apply(); 238 imageQueuedPromise.reject({'data': 'invalid'});
239 $rootScope.$apply();
240 }catch (exp) {
241 expect(exp).toBeDefined();
242 expect(exp.data).toEqual('invalid');
243 }
233 244
234 expect(apiService.put.calls.count()).toBe(1); 245 expect(apiService.put.calls.count()).toBe(1);
235 }); 246 });