Merge branch 'fix/gb/improve-merge-request-pipelines-api' into 'master'
Improve internal API for new merge request Closes #27866 See merge request !9304
This commit is contained in:
commit
a87815fbc0
3 changed files with 8 additions and 3 deletions
|
@ -69,7 +69,9 @@ const PipelineStore = require('./pipelines_store');
|
|||
return pipelinesService.all()
|
||||
.then(response => response.json())
|
||||
.then((json) => {
|
||||
this.store.storePipelines(json);
|
||||
// depending of the endpoint the response can either bring a `pipelines` key or not.
|
||||
const pipelines = json.pipelines || json;
|
||||
this.store.storePipelines(pipelines);
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(() => {
|
||||
|
|
|
@ -245,9 +245,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
|
|||
format.json do
|
||||
define_pipelines_vars
|
||||
|
||||
render json: PipelineSerializer
|
||||
render json: {
|
||||
pipelines: PipelineSerializer
|
||||
.new(project: @project, user: @current_user)
|
||||
.represent(@pipelines)
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,7 +43,8 @@ describe Projects::MergeRequestsController do
|
|||
submit_new_merge_request(format: :json)
|
||||
|
||||
expect(response).to be_ok
|
||||
expect(json_response).not_to be_empty
|
||||
expect(json_response).to have_key 'pipelines'
|
||||
expect(json_response['pipelines']).not_to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue