Skip to content

Commit

Permalink
Merge pull request #18036 from bdunne/action_result_shouldnt_be_nil
Browse files Browse the repository at this point in the history
Currently on a successful ActionResult (start / stop) we return nil

(cherry picked from commit 2fb6260)

https://bugzilla.redhat.com/show_bug.cgi?id=1635764
  • Loading branch information
carbonin authored and simaishi committed Oct 10, 2018
1 parent de7af62 commit a44cae5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/models/mixins/inter_region_api_method_relay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def self.exec_api_call(region, collection_name, action, api_args = nil, id = nil
case result
when ManageIQ::API::Client::ActionResult
raise InterRegionApiMethodRelayError, result.message if result.failed?
result.attributes
when ManageIQ::API::Client::Resource
instance_for_resource(result)
else
Expand Down
8 changes: 4 additions & 4 deletions spec/models/mixins/inter_region_api_method_relay_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,24 +231,24 @@ def expect_api_call(expected_action, expected_args = nil)
it "calls the given action with the given args" do
args = {:my => "args", :here => 123}
expect(api_collection).to receive(action).with(args).and_return(api_success_result)
described_class.exec_api_call(region, collection_name, action, args)
expect(described_class.exec_api_call(region, collection_name, action, args)).to eq(api_success_result.attributes)
end

it "defaults the args to an empty hash" do
expect(api_collection).to receive(action).with({}).and_return(api_success_result)
described_class.exec_api_call(region, collection_name, action)
expect(described_class.exec_api_call(region, collection_name, action)).to eq(api_success_result.attributes)
end

it "defaults the args to an empty hash when nil is explicitly passed as args" do
expect(api_collection).to receive(action).with({}).and_return(api_success_result)
described_class.exec_api_call(region, collection_name, action, nil)
expect(described_class.exec_api_call(region, collection_name, action, nil)).to eq(api_success_result.attributes)
end

it "calls a method on an instance if id is passed" do
instance = double("instance")
expect(api_collection).to receive(:find).with(4).and_return(instance)
expect(instance).to receive(action).and_return(api_success_result)
described_class.exec_api_call(region, collection_name, action, nil, 4)
expect(described_class.exec_api_call(region, collection_name, action, nil, 4)).to eq(api_success_result.attributes)
end
end
end
Expand Down

0 comments on commit a44cae5

Please sign in to comment.