BigW Consortium Gitlab

Commit 71c80375 by Fatih Acet

Merge branch 'fix/gb/invalid-new-merge-request-api' into 'master'

Fix rendering pipelines for a new merge request See merge request !9032
parents 9aafb2a6 d410c937
...@@ -229,9 +229,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -229,9 +229,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
respond_to do |format| respond_to do |format|
format.html { define_new_vars } format.html { define_new_vars }
format.json do format.json do
render json: { pipelines: PipelineSerializer define_pipelines_vars
render json: PipelineSerializer
.new(project: @project, user: @current_user) .new(project: @project, user: @current_user)
.represent(@pipelines) } .represent(@pipelines)
end end
end end
end end
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
-# This tab is always loaded via AJAX -# This tab is always loaded via AJAX
- if @pipelines.any? - if @pipelines.any?
#pipelines.pipelines.tab-pane #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 .mr-loading-status
= spinner = spinner
......
= 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 ...@@ -33,11 +33,17 @@ describe Projects::MergeRequestsController do
end end
context 'when rendering JSON response' do 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 it 'renders JSON including serialized pipelines' do
submit_new_merge_request(format: :json) submit_new_merge_request(format: :json)
expect(json_response).to have_key('pipelines')
expect(response).to be_ok expect(response).to be_ok
expect(json_response).not_to be_empty
end end
end end
end end
......
...@@ -84,4 +84,24 @@ feature 'Create New Merge Request', feature: true, js: true do ...@@ -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_selector('#error_explanation')
expect(page).not_to have_content('The form contains the following error') expect(page).not_to have_content('The form contains the following error')
end 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 end
...@@ -88,3 +88,5 @@ const pipeline = { ...@@ -88,3 +88,5 @@ const pipeline = {
created_at: '2017-01-16T17:13:59.800Z', created_at: '2017-01-16T17:13:59.800Z',
updated_at: '2017-01-25T00:00:17.132Z', updated_at: '2017-01-25T00:00:17.132Z',
}; };
module.exports = pipeline;
/* global pipeline, Vue */ /* global pipeline, Vue */
require('vue-resource'); require('~/flash');
require('flash');
require('~/commit/pipelines/pipelines_store'); require('~/commit/pipelines/pipelines_store');
require('~/commit/pipelines/pipelines_service'); require('~/commit/pipelines/pipelines_service');
require('~/commit/pipelines/pipelines_table'); require('~/commit/pipelines/pipelines_table');
require('~vue_shared/vue_resource_interceptor'); require('~/vue_shared/vue_resource_interceptor');
require('./mock_data'); const pipeline = require('./mock_data');
describe('Pipelines table in Commits and Merge requests', () => { describe('Pipelines table in Commits and Merge requests', () => {
preloadFixtures('pipelines_table'); preloadFixtures('static/pipelines_table.html.raw');
beforeEach(() => { beforeEach(() => {
loadFixtures('pipelines_table'); loadFixtures('static/pipelines_table.html.raw');
}); });
describe('successfull request', () => { describe('successfull request', () => {
......
require('~commit/pipelines/pipelines_store'); require('~/commit/pipelines/pipelines_store');
describe('Store', () => { describe('Store', () => {
const store = gl.commits.pipelines.PipelinesStore; let store;
beforeEach(() => { beforeEach(() => {
store.create(); store = new gl.commits.pipelines.PipelinesStore();
}); });
it('should start with a blank state', () => { it('should start with a blank state', () => {
...@@ -23,7 +23,7 @@ describe('Store', () => { ...@@ -23,7 +23,7 @@ describe('Store', () => {
}, },
]; ];
store.store(pipelines); store.storePipelines(pipelines);
expect(store.state.pipelines.length).toBe(pipelines.length); expect(store.state.pipelines.length).toBe(pipelines.length);
}); });
......
require('~/vue_shared/components/committ'); require('~/vue_shared/components/commit');
describe('Commit component', () => { describe('Commit component', () => {
let props; let props;
......
/* global pipeline */ require('~/vue_shared/components/pipelines_table_row');
const pipeline = require('../../commit/pipelines/mock_data');
require('~vue_shared/components/pipelines_table_row');
require('./mock_data');
describe('Pipelines Table Row', () => { describe('Pipelines Table Row', () => {
let component; let component;
......
/* global pipeline */ require('~/vue_shared/components/pipelines_table');
require('~/lib/utils/datetime_utility');
require('~vue_shared/components/pipelines_table'); const pipeline = require('../../commit/pipelines/mock_data');
require('~lib/utils/datetime_utility');
require('./mock_data');
describe('Pipelines Table', () => { describe('Pipelines Table', () => {
preloadFixtures('static/environments/element.html.raw'); preloadFixtures('static/environments/element.html.raw');
......
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