Skip to content

Commit

Permalink
Fixed enable/disable of Validate button.
Browse files Browse the repository at this point in the history
Styling changes in ManageIQ#2004 have caused `@edit[:new][:data]` value to be set to nil which disables Validate button on screen.

https://bugzilla.redhat.com/show_bug.cgi?id=1499881
  • Loading branch information
h-kataria committed Nov 13, 2017
1 parent 66266f4 commit 07d5355
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/miq_ae_class_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,8 @@ def form_method_field_changed
elsif params[:cls_method_location] || params[:method_location]
# reset data if location is changed
''
else
@edit[:new][:data]
end
build_ae_tree(:ae_methods, :automate_tree)
@changed = (@edit[:new] != @edit[:current])
Expand Down
33 changes: 33 additions & 0 deletions spec/controllers/miq_ae_class_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -878,4 +878,37 @@
controller.send(:replace_right_cell, :replace_trees => %i(ae))
end
end

context "method data edit" do
before do
stub_user(:features => :all)
@method = FactoryGirl.create(:miq_ae_method, :name => "method01", :scope => "class",
:language => "ruby", :class_id => "someid", :data => "exit MIQ_OK", :location => "inline")
controller.instance_variable_set(:@sb, :trees => {:ae_tree => {:active_node => "aec-someid"}},
:active_tree => :ae_tree, :form_vars_set => true)
end

it "make sure data in data field still exists when edititng that field" do
new = {
:name => @method.name,
:language => 'ruby',
:scope => 'instance',
:location => 'inline',
:data => "exit MIQ_OK",
:fields => []
}
session[:edit] = {
:key => "aemethod_edit__#{@method.id}",
:fields_to_delete => [],
:ae_class_id => "someid",
:new_field => {},
:new => new,
:current => new
}
controller.instance_variable_set(:@_params, :transOne => "1", :id => @method.id)
allow(controller).to receive(:render)
controller.send(:form_method_field_changed)
expect(assigns(:edit)[:new][:data]).to eq("exit MIQ_OK...")
end
end
end

0 comments on commit 07d5355

Please sign in to comment.