Don't expose all namespace fields in API

This commit is contained in:
Markus Koller 2016-11-29 20:25:41 +01:00
parent 845e2d3667
commit d05dd81b99
No known key found for this signature in database
GPG key ID: A2B74A05A7A2B7B7
2 changed files with 14 additions and 2 deletions

View file

@ -88,7 +88,7 @@ module API
expose :shared_runners_enabled
expose :lfs_enabled?, as: :lfs_enabled
expose :creator_id
expose :namespace
expose :namespace, using: 'API::Entities::Namespace'
expose :forked_from_project, using: Entities::BasicProjectDetails, if: lambda{ |project, options| project.forked? }
expose :avatar_url
expose :star_count, :forks_count
@ -391,7 +391,7 @@ module API
end
class Namespace < Grape::Entity
expose :id, :path, :kind
expose :id, :name, :path, :kind
end
class MemberAccess < Grape::Entity

View file

@ -630,6 +630,18 @@ describe API::Projects, api: true do
expect(json_response['name']).to eq(project.name)
end
it 'exposes namespace fields' do
get api("/projects/#{project.id}", user)
expect(response).to have_http_status(200)
expect(json_response['namespace']).to eq({
'id' => user.namespace.id,
'name' => user.namespace.name,
'path' => user.namespace.path,
'kind' => user.namespace.kind,
})
end
describe 'permissions' do
context 'all projects' do
before { project.team << [user, :master] }