Skip to content

Commit

Permalink
Passes result_format when automate workspace is not expected.
Browse files Browse the repository at this point in the history
Dynamic dialog expects a workspace object.
  • Loading branch information
lfu committed Oct 17, 2019
1 parent 04efa94 commit 604f13a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/models/custom_button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def applies_to=(other)
end

def invoke(target, source = nil)
args = resource_action.automate_queue_hash(target, {}, User.current_user)
args = resource_action.automate_queue_hash(target, {"result_format" => 'ignore'}, User.current_user)

publish_event(source, target, args)
MiqQueue.put(queue_opts(target, args))
Expand Down Expand Up @@ -142,7 +142,7 @@ def invoke_async(target, source = nil)
:userid => User.current_user
}

args = resource_action.automate_queue_hash(target, {}, User.current_user)
args = resource_action.automate_queue_hash(target, {"result_format" => 'ignore'}, User.current_user)

publish_event(source, target, args)
MiqTask.generic_action_with_callback(task_opts, queue_opts(target, args))
Expand Down
1 change: 0 additions & 1 deletion app/models/resource_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def automate_queue_hash(target, override_attrs, user, open_url_task_id = nil)
end

attrs = (ae_attributes || {}).merge(override_attrs || {})
attrs["result_format"] = 'ignore'

{
:namespace => ae_namespace,
Expand Down
10 changes: 7 additions & 3 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) { { "result_format" => "ignore"} }
let(:ae_attributes) { {} }
let(:q_args) do
{
:namespace => nil,
Expand Down Expand Up @@ -114,8 +114,12 @@
let(:user) { FactoryBot.create(:user_with_group) }
let(:target) { FactoryBot.create(:vm_vmware) }

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

it "does not pass result_format by default" do
expect(ra.automate_queue_hash(target, {}, user)).not_to include(:attrs => {"result_format"=>"ignore"})
end
end
end

0 comments on commit 604f13a

Please sign in to comment.