Commit a87815fb authored by Kamil Trzciński's avatar 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
parents b3700dea 8f3c8448
...@@ -69,7 +69,9 @@ const PipelineStore = require('./pipelines_store'); ...@@ -69,7 +69,9 @@ const PipelineStore = require('./pipelines_store');
return pipelinesService.all() return pipelinesService.all()
.then(response => response.json()) .then(response => response.json())
.then((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; this.isLoading = false;
}) })
.catch(() => { .catch(() => {
......
...@@ -245,9 +245,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -245,9 +245,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
format.json do format.json do
define_pipelines_vars define_pipelines_vars
render json: PipelineSerializer render json: {
pipelines: PipelineSerializer
.new(project: @project, user: @current_user) .new(project: @project, user: @current_user)
.represent(@pipelines) .represent(@pipelines)
}
end end
end end
end end
......
...@@ -43,7 +43,8 @@ describe Projects::MergeRequestsController do ...@@ -43,7 +43,8 @@ describe Projects::MergeRequestsController do
submit_new_merge_request(format: :json) submit_new_merge_request(format: :json)
expect(response).to be_ok 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 end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment