Skip to content

Commit

Permalink
Merge pull request #1190 from lgalis/initialize_delete_backing_for_vm…
Browse files Browse the repository at this point in the history
…_disk_reconfigure

Initialize the delete_backing flag for existing VM disks in the reconfigure form
  • Loading branch information
h-kataria authored May 8, 2017
2 parents c210641 + e34672c commit 8a195f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,11 @@ ManageIQ.angular.app.controller('reconfigureFormController', ['$http', '$scope',
$scope.updateDisksAddRemove();

angular.forEach($scope.reconfigureModel.vmdisks, function(disk) {
if ($scope.reconfigureModel.vmdisks[disk] !== undefined
&& $scope.reconfigureModel.vmdisks[disk].add_remove === '' ) {
$scope.reconfigureModel.vmdisks[disk].delete_backing = false;
if (disk !== undefined
&& ( disk.add_remove !== 'add' && disk.add_remove !== 'remove' )) {
disk.delete_backing = false;
}
});

if (data.socket_count && data.cores_per_socket_count) {
$scope.reconfigureModel.total_cpus = (parseInt($scope.reconfigureModel.socket_count, 10) * parseInt($scope.reconfigureModel.cores_per_socket_count, 10)).toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ describe('reconfigureFormController', function() {
memory_type: 'MB',
cb_cpu: 'on',
socket_count: '2',
cores_per_socket_count: '3'};
cores_per_socket_count: '3',
disks: [{hdFilename: "test_disk.vmdk", hdType: "thick", hdMode: "persistent", hdSize: "0", hdUnit: "MB", add_remove: ""}]};
$httpBackend.whenGET('reconfigure_form_fields/1000000000003,1000000000001,1000000000002').respond(reconfigureFormResponse);
$httpBackend.flush();
}));
Expand All @@ -59,6 +60,10 @@ describe('reconfigureFormController', function() {
it('sets the total socket count to the value calculated from the http request data', function() {
expect($scope.reconfigureModel.total_cpus).toEqual('6');
});

it('initializes the delete_backing flag to false if not retrived', function() {
expect($scope.reconfigureModel.vmdisks).toEqual([{hdFilename: "test_disk.vmdk", hdType: "thick", hdMode: "persistent", hdSize: "0", hdUnit: "MB", add_remove: "", delete_backing: false}]);
});
});

describe('#cancelClicked', function() {
Expand Down

0 comments on commit 8a195f6

Please sign in to comment.