Skip to content

Commit

Permalink
Currently on a successful ActionResult (start / stop) we return nil
Browse files Browse the repository at this point in the history
Returning the result of the api call would at least be a positive result
https://bugzilla.redhat.com/show_bug.cgi?id=1628658
  • Loading branch information
bdunne committed Sep 28, 2018
1 parent 328f688 commit 4b81358
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
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 be(api_success_result)
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 be(api_success_result)
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 be(api_success_result)
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 be(api_success_result)
end
end
end
Expand Down

0 comments on commit 4b81358

Please sign in to comment.