Narrow environment payload by using basic project details resource

This commit is contained in:
Oswaldo Ferreira 2017-03-02 17:36:21 -03:00
parent b63c41e12e
commit fa0c0bb006
4 changed files with 10 additions and 3 deletions

View File

@ -0,0 +1,4 @@
---
title: Narrow environment payload by using basic project details resource
merge_request:
author:

View File

@ -68,3 +68,5 @@ changes are in V4:
- Rename Build Triggers to be Pipeline Triggers API [!9713](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9713)
- `POST /projects/:id/trigger/builds` to `POST /projects/:id/trigger/pipeline`
- Require description when creating a new trigger `POST /projects/:id/triggers`
- Simplify project payload exposed on Environment endpoints [!9675](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9675)

View File

@ -671,7 +671,7 @@ module API
end
class Environment < EnvironmentBasic
expose :project, using: Entities::Project
expose :project, using: Entities::BasicProjectDetails
end
class Deployment < Grape::Entity

View File

@ -15,6 +15,8 @@ describe API::Environments, api: true do
describe 'GET /projects/:id/environments' do
context 'as member of the project' do
it 'returns project environments' do
project_data_keys = %w(id http_url_to_repo web_url name name_with_namespace path path_with_namespace)
get api("/projects/#{project.id}/environments", user)
expect(response).to have_http_status(200)
@ -23,8 +25,7 @@ describe API::Environments, api: true do
expect(json_response.size).to eq(1)
expect(json_response.first['name']).to eq(environment.name)
expect(json_response.first['external_url']).to eq(environment.external_url)
expect(json_response.first['project']['id']).to eq(project.id)
expect(json_response.first['project']['visibility']).to be_present
expect(json_response.first['project'].keys).to contain_exactly(*project_data_keys)
end
end