From 4a008b986a70b78e0af83366463d1287333e6dbf Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Sun, 18 Dec 2016 15:16:37 -0500 Subject: [PATCH] Fixed params[:field_typ] value check. https://bugzilla.redhat.com/show_bug.cgi?id=1319781 --- .../dialogs.rb | 2 +- .../dialogs_spec.rb | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/app/controllers/miq_ae_customization_controller/dialogs.rb b/app/controllers/miq_ae_customization_controller/dialogs.rb index 7b2b4e0d271..97b4f7e2c3a 100644 --- a/app/controllers/miq_ae_customization_controller/dialogs.rb +++ b/app/controllers/miq_ae_customization_controller/dialogs.rb @@ -877,7 +877,7 @@ def dialog_get_form_vars_field end # initialize data type for textbox - if params[:field_typ] == 'TextBox' + if params[:field_typ] == 'DialogFieldTextBox' @edit[:field_data_typ] = key[:data_typ] = "string" end diff --git a/spec/controllers/miq_ae_customization_controller/dialogs_spec.rb b/spec/controllers/miq_ae_customization_controller/dialogs_spec.rb index 2c6e6173b72..e78f0317ecb 100644 --- a/spec/controllers/miq_ae_customization_controller/dialogs_spec.rb +++ b/spec/controllers/miq_ae_customization_controller/dialogs_spec.rb @@ -123,6 +123,38 @@ expect(@dialog.dialog_fields.count).to eq(2) expect(@dialog.dialog_fields.last[:data_type]).to eq("integer") end + + it "initializes Value Type of new text box to String" do + allow(controller).to receive(:x_node) { 'root_-0_-0_-0' } + new_hash = { + :label => "Dialog 1", + :description => "Dialog 1", + :buttons => ["submit"], + :tabs => [ + { + :label => "Tab 1", + :description => "Tab 1", + :groups => [ + { + :label => "Box 1", + :description => "Box 1", + :fields => [ + { + :typ => "DialogFieldTextBox", + } + ] + } + ] + } + ] + } + assigns(:edit)[:new] = new_hash + controller.instance_variable_set(:@_params, :id => 'new', :field_typ => "DialogFieldTextBox") + controller.instance_variable_set(:@sb, :node_typ => 'element') + expect(controller).to receive(:render) + controller.send(:dialog_form_field_changed) + expect(assigns(:edit)[:field_data_typ]).to eq("string") + end end it "Empty dropdown element has to be invalid" do