Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set result_format to ignore for all custom buttons. #19270

Merged
merged 1 commit into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/resource_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def automate_queue_hash(target, override_attrs, user, open_url_task_id = nil)
end

attrs = (ae_attributes || {}).merge(override_attrs || {})
attrs["result_format"] = 'ignore' if resource&.options&.dig(:open_url)
attrs["result_format"] = 'ignore'

{
:namespace => ae_namespace,
Expand Down
11 changes: 3 additions & 8 deletions spec/models/resource_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let(:zone_name) { "default" }
let(:ra) { FactoryBot.create(:resource_action) }
let(:miq_server) { FactoryBot.create(:miq_server) }
let(:ae_attributes) { {} }
let(:ae_attributes) { { "result_format" => "ignore"} }
let(:q_args) do
{
:namespace => nil,
Expand Down Expand Up @@ -109,18 +109,13 @@
end

context "#automate_queue_hash" do
let(:button) { FactoryBot.create(:custom_button, :options => {:open_url => true}, :applies_to_class => "Vm") }
let(:button) { FactoryBot.create(:custom_button, :applies_to_class => "Vm") }
let(:ra) { FactoryBot.create(:resource_action, :resource => button) }
let(:user) { FactoryBot.create(:user_with_group) }
let(:target) { FactoryBot.create(:vm_vmware) }

it "adds result_format for open_url" do
it "adds result_format" do
expect(ra.automate_queue_hash(target, {}, user)).to include(:attrs => {"result_format"=>"ignore"})
end

it "does not add result_format for not open_url" do
button.options[:open_url] = false
expect(ra.automate_queue_hash(target, {}, user)).not_to include(:attrs => {"result_format"=>"ignore"})
end
end
end