Merge branch 'fix/gb/invalid-new-merge-request-api' into 'master'
Fix rendering pipelines for a new merge request See merge request !9032
This commit is contained in:
commit
71c8037547
11 changed files with 52 additions and 25 deletions
|
@ -229,9 +229,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
|
|||
respond_to do |format|
|
||||
format.html { define_new_vars }
|
||||
format.json do
|
||||
render json: { pipelines: PipelineSerializer
|
||||
define_pipelines_vars
|
||||
|
||||
render json: PipelineSerializer
|
||||
.new(project: @project, user: @current_user)
|
||||
.represent(@pipelines) }
|
||||
.represent(@pipelines)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
-# This tab is always loaded via AJAX
|
||||
- if @pipelines.any?
|
||||
#pipelines.pipelines.tab-pane
|
||||
= render "projects/merge_requests/show/pipelines", endpoint: link_to(url_for(params))
|
||||
= render 'projects/merge_requests/show/pipelines', endpoint: url_for(params.merge(format: :json))
|
||||
|
||||
.mr-loading-status
|
||||
= spinner
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
= render 'projects/commit/pipelines_list', endpoint: pipelines_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)
|
||||
- endpoint_path = local_assigns[:endpoint] || pipelines_namespace_project_merge_request_path(@project.namespace, @project, @merge_request, format: :json)
|
||||
|
||||
= render 'projects/commit/pipelines_list', endpoint: endpoint_path
|
||||
|
|
|
@ -33,11 +33,17 @@ describe Projects::MergeRequestsController do
|
|||
end
|
||||
|
||||
context 'when rendering JSON response' do
|
||||
before do
|
||||
create(:ci_pipeline, sha: fork_project.commit('remove-submodule').id,
|
||||
ref: 'remove-submodule',
|
||||
project: fork_project)
|
||||
end
|
||||
|
||||
it 'renders JSON including serialized pipelines' do
|
||||
submit_new_merge_request(format: :json)
|
||||
|
||||
expect(json_response).to have_key('pipelines')
|
||||
expect(response).to be_ok
|
||||
expect(json_response).not_to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -84,4 +84,24 @@ feature 'Create New Merge Request', feature: true, js: true do
|
|||
expect(page).not_to have_selector('#error_explanation')
|
||||
expect(page).not_to have_content('The form contains the following error')
|
||||
end
|
||||
|
||||
context 'when a new merge request has a pipeline' do
|
||||
let!(:pipeline) do
|
||||
create(:ci_pipeline, sha: project.commit('fix').id,
|
||||
ref: 'fix',
|
||||
project: project)
|
||||
end
|
||||
|
||||
it 'shows pipelines for a new merge request' do
|
||||
visit new_namespace_project_merge_request_path(
|
||||
project.namespace, project,
|
||||
merge_request: { target_branch: 'master', source_branch: 'fix' })
|
||||
|
||||
page.within('.merge-request') do
|
||||
click_link 'Pipelines'
|
||||
|
||||
expect(page).to have_content "##{pipeline.id}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -88,3 +88,5 @@ const pipeline = {
|
|||
created_at: '2017-01-16T17:13:59.800Z',
|
||||
updated_at: '2017-01-25T00:00:17.132Z',
|
||||
};
|
||||
|
||||
module.exports = pipeline;
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
/* global pipeline, Vue */
|
||||
|
||||
require('vue-resource');
|
||||
require('flash');
|
||||
require('~/flash');
|
||||
require('~/commit/pipelines/pipelines_store');
|
||||
require('~/commit/pipelines/pipelines_service');
|
||||
require('~/commit/pipelines/pipelines_table');
|
||||
require('~vue_shared/vue_resource_interceptor');
|
||||
require('./mock_data');
|
||||
require('~/vue_shared/vue_resource_interceptor');
|
||||
const pipeline = require('./mock_data');
|
||||
|
||||
describe('Pipelines table in Commits and Merge requests', () => {
|
||||
preloadFixtures('pipelines_table');
|
||||
preloadFixtures('static/pipelines_table.html.raw');
|
||||
|
||||
beforeEach(() => {
|
||||
loadFixtures('pipelines_table');
|
||||
loadFixtures('static/pipelines_table.html.raw');
|
||||
});
|
||||
|
||||
describe('successfull request', () => {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require('~commit/pipelines/pipelines_store');
|
||||
require('~/commit/pipelines/pipelines_store');
|
||||
|
||||
describe('Store', () => {
|
||||
const store = gl.commits.pipelines.PipelinesStore;
|
||||
let store;
|
||||
|
||||
beforeEach(() => {
|
||||
store.create();
|
||||
store = new gl.commits.pipelines.PipelinesStore();
|
||||
});
|
||||
|
||||
it('should start with a blank state', () => {
|
||||
|
@ -23,7 +23,7 @@ describe('Store', () => {
|
|||
},
|
||||
];
|
||||
|
||||
store.store(pipelines);
|
||||
store.storePipelines(pipelines);
|
||||
|
||||
expect(store.state.pipelines.length).toBe(pipelines.length);
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require('~/vue_shared/components/committ');
|
||||
require('~/vue_shared/components/commit');
|
||||
|
||||
describe('Commit component', () => {
|
||||
let props;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
/* global pipeline */
|
||||
|
||||
require('~vue_shared/components/pipelines_table_row');
|
||||
require('./mock_data');
|
||||
require('~/vue_shared/components/pipelines_table_row');
|
||||
const pipeline = require('../../commit/pipelines/mock_data');
|
||||
|
||||
describe('Pipelines Table Row', () => {
|
||||
let component;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
/* global pipeline */
|
||||
|
||||
require('~vue_shared/components/pipelines_table');
|
||||
require('~lib/utils/datetime_utility');
|
||||
require('./mock_data');
|
||||
require('~/vue_shared/components/pipelines_table');
|
||||
require('~/lib/utils/datetime_utility');
|
||||
const pipeline = require('../../commit/pipelines/mock_data');
|
||||
|
||||
describe('Pipelines Table', () => {
|
||||
preloadFixtures('static/environments/element.html.raw');
|
||||
|
|
Loading…
Reference in a new issue