Merge "Fix incorrect volume type value in ng images create volume form"

This commit is contained in:
Zuul 2018-01-03 21:15:21 +00:00 committed by Gerrit Code Review
commit edf72bd30c
2 changed files with 10 additions and 14 deletions

View File

@ -135,11 +135,11 @@
updateStorageGraph
);
var volumeWatcher = $scope.$watch(
var volumeTypeWatcher = $scope.$watch(
function() {
return ctrl.volume;
return ctrl.volumeType;
},
volumeChangeEvent,
updateVolumeType,
true
);
@ -222,13 +222,13 @@
return image.name + ' (' + $filter('bytes')(image.size) + ')';
}
function volumeChangeEvent() {
function updateVolumeType() {
ctrl.volume.volume_type = ctrl.volumeType.name || '';
}
function deregisterWatchers() {
capacityWatcher();
volumeWatcher();
volumeTypeWatcher();
}
}
})();

View File

@ -272,16 +272,12 @@
expect(graph.maxLimit).toEqual(graph.maxLimit);
});
it('should update volume type from volume name', function() {
it('should update volume type when ctrl.volumeType changes', function() {
var ctrl = createController();
ctrl.volumeType = {name: 'spam'};
$scope.$apply();
ctrl.volume.volume_type = 'spam';
ctrl.volume.name = 'nova2';
$scope.$apply();
expect(ctrl.volume.volume_type).toEqual('lvmdriver-1');
expect(ctrl.volume.volume_type).toEqual('spam');
});
it('should set the validity of the volume size input field based on the limit', function() {
@ -342,13 +338,13 @@
expect(graph.overMax).toBeFalsy();
});
it('should deregister the volume watcher when the destroy event is thrown', function() {
it('should deregister the volume type watcher when the destroy event is thrown', function() {
var ctrl = createController();
$scope.$emit('$destroy');
$scope.$emit.calls.reset();
ctrl.volume.size = 100;
ctrl.volumeType = {name: 'spam'};
$scope.$apply();
expect($scope.$emit).not.toHaveBeenCalled();