Skip to content

Commit

Permalink
Merge pull request #3236 from lgalis/fix_update_and_reset_button_on_c…
Browse files Browse the repository at this point in the history
…atalog

Set the action parameter  replace_right_cell's  on button update and reset
(cherry picked from commit 6f8c0b9)

https://bugzilla.redhat.com/show_bug.cgi?id=1534058
  • Loading branch information
h-kataria authored and simaishi committed Jan 12, 2018
1 parent 0fc57bc commit f9f6ba2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/controllers/application_controller/buttons.rb
Expand Up @@ -501,7 +501,7 @@ def ab_expression
@edit[:enablement_expression_table] = exp_build_table_or_nil(@edit[:new][:enablement_expression])
@in_a_form = true
@sb[:active_tab] = "ab_advanced_tab"
replace_right_cell(:nodetype => x_node)
replace_right_cell(:action => 'button_edit')
end

def ab_button_cancel(typ)
Expand Down Expand Up @@ -632,7 +632,7 @@ def ab_button_reset
drop_breadcrumb(:name => _("Edit of Button"), :url => "/miq_ae_customization/button_edit")
@lastaction = "automate_button"
@layout = "miq_ae_automate_button"
replace_right_cell(:nodetype => "button_edit")
replace_right_cell(:action => "button_edit")
end

# Set form variables for button add/edit
Expand Down
34 changes: 34 additions & 0 deletions spec/controllers/application_controller/buttons_spec.rb
Expand Up @@ -135,6 +135,40 @@
controller.send(:button_create_update, "add")
expect(assigns(:sb)[:active_tab]).to eq("ab_advanced_tab")
end

it "calls replace_right_cell with action='button_edit' when the edit expression button was pressed" do
custom_button = FactoryGirl.create(:custom_button, :applies_to_class => "Host")
controller.instance_variable_set(:@_params, :button => "enablement_expression", :id => custom_button.id)
edit = {:new => {},
:current => {},
:custom_button => custom_button}
controller.instance_variable_set(:@edit, edit)
session[:edit] = edit
controller.instance_variable_set(:@sb,
:trees => {:ab_tree => {:active_node => "-ub-Host"}},
:active_tree => :ab_tree)
allow(controller).to receive(:ab_get_node_info)
allow(controller).to receive(:exp_build_table_or_nil).and_return(nil)
expect(controller).to receive(:replace_right_cell).with(:action => 'button_edit')
controller.send(:button_create_update, "edit")
end

it "calls replace_right_cell with action='button_edit' when the edit expression button was pressed" do
custom_button = FactoryGirl.create(:custom_button, :applies_to_class => "Host")
controller.instance_variable_set(:@_params, :button => "enablement_expression", :id => custom_button.id)
edit = {:new => {},
:current => {},
:custom_button => custom_button}
controller.instance_variable_set(:@edit, edit)
session[:edit] = edit
controller.instance_variable_set(:@sb,
:trees => {:ab_tree => {:active_node => "-ub-Host"}},
:active_tree => :ab_tree)
allow(controller).to receive(:ab_get_node_info)
allow(controller).to receive(:exp_build_table_or_nil).and_return(nil)
expect(controller).to receive(:replace_right_cell).with(:action => 'button_edit')
controller.send(:button_create_update, "reset")
end
end
end

Expand Down

0 comments on commit f9f6ba2

Please sign in to comment.