Merge "Fix incorrect volume type value in ng images create volume form" into stable/pike

This commit is contained in:
Zuul 2018-01-04 09:21:06 +00:00 committed by Gerrit Code Review
commit 442bc930dc
2 changed files with 10 additions and 14 deletions

View File

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

View File

@ -272,16 +272,12 @@
expect(graph.maxLimit).toEqual(graph.maxLimit); 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(); var ctrl = createController();
ctrl.volumeType = {name: 'spam'};
$scope.$apply(); $scope.$apply();
ctrl.volume.volume_type = 'spam'; expect(ctrl.volume.volume_type).toEqual('spam');
ctrl.volume.name = 'nova2';
$scope.$apply();
expect(ctrl.volume.volume_type).toEqual('lvmdriver-1');
}); });
it('should set the validity of the volume size input field based on the limit', function() { it('should set the validity of the volume size input field based on the limit', function() {
@ -342,13 +338,13 @@
expect(graph.overMax).toBeFalsy(); 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(); var ctrl = createController();
$scope.$emit('$destroy'); $scope.$emit('$destroy');
$scope.$emit.calls.reset(); $scope.$emit.calls.reset();
ctrl.volume.size = 100; ctrl.volumeType = {name: 'spam'};
$scope.$apply(); $scope.$apply();
expect($scope.$emit).not.toHaveBeenCalled(); expect($scope.$emit).not.toHaveBeenCalled();