Skip to content

Commit

Permalink
Merge pull request #13235 from h-kataria/dialog_text_field_initializa…
Browse files Browse the repository at this point in the history
…tion_fix

Fixed params[:field_typ] value check.
  • Loading branch information
Dan Clarizio authored Dec 19, 2016
2 parents 08521d6 + 4a008b9 commit 7dce38b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/miq_ae_customization_controller/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 32 additions & 0 deletions spec/controllers/miq_ae_customization_controller/dialogs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7dce38b

Please sign in to comment.