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

Make cloud_tenants and flavors subcollections consistent with others #321

Merged
merged 1 commit into from
Feb 14, 2018
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/controllers/api/subcollections/cloud_tenants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Api
module Subcollections
module CloudTenants
def cloud_tenants_query_resource(object)
object.cloud_tenants
object.respond_to?(:cloud_tenants) ? object.cloud_tenants : []
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/subcollections/flavors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Api
module Subcollections
module Flavors
def flavors_query_resource(object)
object.flavors
object.respond_to?(:flavors) ? object.flavors : []
end

def flavors_create_resource(parent, _type, _id, data)
Expand Down
12 changes: 12 additions & 0 deletions spec/requests/cloud_tenants_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,16 @@
expect(response).to have_http_status(:forbidden)
end
end

context 'As a subcollection' do
it 'returns an empty array for collections that do not have cloud tenants' do
ems_infra = FactoryGirl.create(:ems_infra)
api_basic_authorize(subcollection_action_identifier(:providers, :cloud_tenants, :read, :get))

get(api_provider_cloud_tenants_url(nil, ems_infra))

expect(response).to have_http_status(:ok)
expect(response.parsed_body).to include('resources' => [])
end
end
end
10 changes: 10 additions & 0 deletions spec/requests/flavors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@

expect(response).to have_http_status(:forbidden)
end

it 'returns an empty array for collections that do not have flavors' do
ems_infra = FactoryGirl.create(:ems_infra)
api_basic_authorize(subcollection_action_identifier(:providers, :flavors, :read, :get))

get(api_provider_flavors_url(nil, ems_infra))

expect(response).to have_http_status(:ok)
expect(response.parsed_body).to include('resources' => [])
end
end

describe "GET /api/providers/:c_id/flavors/:id" do
Expand Down