Skip to content

Commit

Permalink
Return empty AR relation instead of nil
Browse files Browse the repository at this point in the history
InfraProvider don't have relation to cloud_tenants - there was
created only empty method returning nil to preserve consitency - but on
some places is expected AR relation object.

For example screen add new subnet, there are listed network managers and
their parent manager's cloud_tenants but they can be infra manager whithout
cloud_tenants.

Such place, where was expected AR Relation object is here:
https://github.com/ManageIQ/manageiq-api/blob/master/app/controllers/api/subcollections/cloud_tenants.rb#L5

which was reached for example by this request:

http://localhost:3000/api/providers/:id/cloud_tenants but it fails later
when object has been infra manager and the method cloud_tenants_query_resource
was returning nil.
  • Loading branch information
lpichler committed Jan 3, 2018
1 parent 908033f commit a39cb4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/manageiq/providers/openstack/infra_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def availability_zones
end

def cloud_tenants
self.class.none
end

def host_aggregates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,10 @@
expect(ems.supported_catalog_types).to eq(%w(openstack))
end
end

let(:openstack_infra_manager) { FactoryGirl.create(:ems_openstack_infra_with_authentication) }

it 'returns empty relation instead of nil when cloud_tenants are requested on infra provider' do
expect(openstack_infra_manager.cloud_tenants).to eq(ManageIQ::Providers::Openstack::InfraManager.none)
end
end

0 comments on commit a39cb4a

Please sign in to comment.