Skip to content

Commit

Permalink
Spec for reset and expression edit on catalog custom button update
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalis committed Jan 12, 2018
1 parent 15dbcfc commit 5a0b57e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions spec/controllers/application_controller/buttons_spec.rb
Original file line number Diff line number Diff line change
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 5a0b57e

Please sign in to comment.