提交 a87815fb 编写于 作者: K Kamil Trzciński

Merge branch 'fix/gb/improve-merge-request-pipelines-api' into 'master'

Improve internal API for new merge request

Closes #27866

See merge request !9304
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册