Skip to content

Commit

Permalink
Merge pull request #13001 from h-kataria/custom_buttons_options_fix
Browse files Browse the repository at this point in the history
Fixed code that sets values of button_image, display & open_url fields
  • Loading branch information
martinpovolny authored Dec 6, 2016
2 parents f0be77c + e9c0b51 commit c34468f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/controllers/application_controller/buttons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -843,9 +843,9 @@ def button_set_form_vars
:target_class => @resolve[:target_class],
:name => @custom_button.name,
:description => @custom_button.description,
:button_image => @custom_button.options.try(:button_image).to_s,
:display => @custom_button.options.try(:display) ? @custom_button.options[:display] : true,
:open_url => @custom_button.options.try(:open_url) ? @custom_button.options[:open_url] : false,
:button_image => @custom_button.options.try(:[], :button_image).to_s,
:display => @custom_button.options.try(:[], :display).nil? ? true : @custom_button.options[:display],
:open_url => @custom_button.options.try(:[], :open_url) ? @custom_button.options[:open_url] : false,
:object_message => @custom_button.uri_message || "create",
)
@edit[:current] = copy_hash(@edit[:new])
Expand Down
5 changes: 4 additions & 1 deletion spec/controllers/application_controller/buttons_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
# which, in turn, needs *something* to come back from automate
allow(MiqAeClass).to receive_messages(:find_distinct_instances_across_domains => [double(:name => "foo")])

custom_button = FactoryGirl.create(:custom_button, :applies_to_class => "Vm")
custom_button = FactoryGirl.create(:custom_button, :applies_to_class => "Vm", :options => {:display => false, :button_image => "5"})
custom_button.uri_path, custom_button.uri_attributes, custom_button.uri_message = CustomButton.parse_uri("/test/")
custom_button.uri_attributes["request"] = "req"
custom_button.save
Expand All @@ -143,6 +143,9 @@
)
controller.send(:button_set_form_vars)
expect(assigns(:edit)[:new][:target_class]).to eq(ui_lookup(:model => "Vm"))
expect(assigns(:edit)[:new][:display]).to eq(false)
expect(assigns(:edit)[:new][:button_image]).to eq('5')
expect(assigns(:edit)[:new][:open_url]).to eq(false)

controller.instance_variable_set(:@sb,
:trees => {
Expand Down

0 comments on commit c34468f

Please sign in to comment.