Skip to content

Commit

Permalink
Fixes value of validation_id in host form
Browse files Browse the repository at this point in the history
https://bugzilla.redhat.com/show_bug.cgi?id=1634794

* validation_id was null in template and blank in controller
* => changed to null everywhere
* it causes dirty state on the form (because the model and the copy was different)
  • Loading branch information
rvsia committed Feb 28, 2019
1 parent 2685812 commit db3e052
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ManageIQ.angular.app.controller('hostFormController', ['$http', '$scope', '$attr
ws_password: '',
ipmi_userid: '',
ipmi_password: '',
validate_id: '',
validate_id: null,
};

$scope.modelCopy = angular.copy( $scope.hostModel );
Expand Down Expand Up @@ -46,7 +46,7 @@ ManageIQ.angular.app.controller('hostFormController', ['$http', '$scope', '$attr
$scope.hostModel.ws_password = '';
$scope.hostModel.ipmi_userid = '';
$scope.hostModel.ipmi_password = '';
$scope.hostModel.validate_id = '';
$scope.hostModel.validate_id = null;
$scope.afterGet = true;
} else if (hostFormId.split(',').length === 1) {
miqService.sparkleOn();
Expand Down
1 change: 1 addition & 0 deletions app/controllers/mixins/ems_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ def form_instance_vars
zones.each do |zone|
@server_zones.push([zone.description, zone.name])
end
binding.pry
@ems_types = Array(model.supported_types_and_descriptions_hash.invert).sort_by(&:first)

@provider_regions = retrieve_provider_regions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@
= _("Select Host to validate against")
.col-md-10
= select_tag('validate_id',
options_for_select([["<#{_('Choose')}>", '']] + @selected_hosts.invert.sort, disabled: ["<#{_('Choose')}>", nil]),
options_for_select([["<#{_('Choose')}>", nil]] + @selected_hosts.invert.sort, disabled: ["<#{_('Choose')}>", nil]),
"ng-model" => "#{ng_model}.validate_id",
"checkchange" => "",
"selectpicker-for-select-tag" => "")
Expand Down
11 changes: 10 additions & 1 deletion spec/javascripts/controllers/host/host_form_controller_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ describe('hostFormController', function() {
it('sets the IPMI Address to blank', function() {
expect($scope.hostModel.ipmi_address).toEqual('');
});

it('sets the validate id to null', function() {
expect($scope.hostModel.validate_id).toEqual(null);
});
});

describe('when the hostFormId is an Id', function() {
Expand All @@ -77,7 +81,8 @@ describe('hostFormController', function() {
default_userid: 'abc',
remote_userid: 'xyz',
ws_userid: 'aaa',
ipmi_userid: 'zzz'
ipmi_userid: 'zzz',
validate_id: '1',
};
describe('when the filter type is all', function() {
beforeEach(inject(function(_$controller_) {
Expand Down Expand Up @@ -127,6 +132,10 @@ describe('hostFormController', function() {
it('sets the ipmi password to the placeholder value if a ipmi user exists', function() {
expect($scope.hostModel.ipmi_password).toEqual(miqService.storedPasswordPlaceholder);
});

it('sets the validate id to the value returned from the http request', function() {
expect($scope.hostModel.validate_id).toEqual('1');
});
});
});
});
Expand Down

0 comments on commit db3e052

Please sign in to comment.