Merge "Add message for a result of update metadata"

This commit is contained in:
Jenkins 2016-09-08 08:17:17 +00:00 committed by Gerrit Code Review
commit 9e711d3e11
2 changed files with 12 additions and 5 deletions

View File

@ -23,8 +23,9 @@
MetadataModalController.$inject = [
'$modalInstance',
'horizon.framework.widgets.metadata.tree.service',
'horizon.app.core.metadata.service',
'horizon.framework.widgets.metadata.tree.service',
'horizon.framework.widgets.toast.service',
// Dependencies injected with resolve by $modal.open
'available',
'existing',
@ -38,8 +39,8 @@
* Controller used by `ModalService`
*/
function MetadataModalController(
$modalInstance, metadataTreeService, metadataService,
available, existing, params
$modalInstance, metadataService, metadataTreeService,
toastService, available, existing, params
) {
var ctrl = this;
@ -80,10 +81,12 @@
}
function onEditSuccess() {
toastService.add('success', gettext('Metadata was successfully updated.'));
$modalInstance.close();
}
function onEditFailure() {
toastService.add('error', gettext('Unable to update metadata.'));
ctrl.saving = false;
}
}

View File

@ -18,7 +18,7 @@
'use strict';
describe('MetadataModalController', function () {
var $controller, treeService, modalInstance;
var $controller, treeService, modalInstance, toast;
var metadataService = {
editMetadata: function() {}
@ -53,10 +53,12 @@
});
beforeEach(module('horizon.app.core.metadata.modal',
'horizon.framework.widgets.metadata.tree'));
'horizon.framework'));
beforeEach(inject(function (_$controller_, $injector) {
$controller = _$controller_;
treeService = $injector.get('horizon.framework.widgets.metadata.tree.service');
toast = $injector.get('horizon.framework.widgets.toast.service');
spyOn(toast, 'add');
}));
it('should dismiss modal on cancel', function () {
@ -84,6 +86,7 @@
expect(modalInstance.close).toHaveBeenCalled();
expect(metadataService.editMetadata)
.toHaveBeenCalledWith('aggregate', '123', {'custom': 'bar'}, ['UPPER_lower']);
expect(toast.add).toHaveBeenCalledWith('success', 'Metadata was successfully updated.');
});
it('should clear saving flag on failed save', function() {
@ -103,6 +106,7 @@
expect(modalInstance.close).not.toHaveBeenCalled();
expect(metadataService.editMetadata)
.toHaveBeenCalledWith('aggregate', '123', {'custom': 'bar'}, ['UPPER_lower']);
expect(toast.add).toHaveBeenCalledWith('error', 'Unable to update metadata.');
});
function createController() {