From db3e052b324861995943aba075867064387e8486 Mon Sep 17 00:00:00 2001 From: Richard Vsiansky Date: Thu, 28 Feb 2019 12:27:32 +0100 Subject: [PATCH] Fixes value of validation_id in host form 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) --- .../controllers/host/host_form_controller.js | 4 ++-- app/controllers/mixins/ems_common.rb | 1 + .../layouts/angular/_multi_auth_credentials.html.haml | 2 +- .../controllers/host/host_form_controller_spec.js | 11 ++++++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/controllers/host/host_form_controller.js b/app/assets/javascripts/controllers/host/host_form_controller.js index afc3e0bc0447..02a4877d264b 100644 --- a/app/assets/javascripts/controllers/host/host_form_controller.js +++ b/app/assets/javascripts/controllers/host/host_form_controller.js @@ -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 ); @@ -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(); diff --git a/app/controllers/mixins/ems_common.rb b/app/controllers/mixins/ems_common.rb index 7d919b294441..dec8cb29dde2 100644 --- a/app/controllers/mixins/ems_common.rb +++ b/app/controllers/mixins/ems_common.rb @@ -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 diff --git a/app/views/layouts/angular/_multi_auth_credentials.html.haml b/app/views/layouts/angular/_multi_auth_credentials.html.haml index 1866de2df1f7..0de42f6f2416 100644 --- a/app/views/layouts/angular/_multi_auth_credentials.html.haml +++ b/app/views/layouts/angular/_multi_auth_credentials.html.haml @@ -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" => "") diff --git a/spec/javascripts/controllers/host/host_form_controller_spec.js b/spec/javascripts/controllers/host/host_form_controller_spec.js index 8de4207fc116..5c67620c8d78 100644 --- a/spec/javascripts/controllers/host/host_form_controller_spec.js +++ b/spec/javascripts/controllers/host/host_form_controller_spec.js @@ -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() { @@ -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_) { @@ -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'); + }); }); }); });