Merge branch 'fix/sm/34547-cannot-connect-to-ci-server-error-messages' into 'master'
Fix "Cannot connect to CI server error messages" Closes #34547 See merge request !13252
This commit is contained in:
commit
edc81ea6c8
|
@ -12,7 +12,6 @@ module MergeRequests
|
||||||
merge_request.source_project = source_project
|
merge_request.source_project = source_project
|
||||||
merge_request.source_branch = params[:source_branch]
|
merge_request.source_branch = params[:source_branch]
|
||||||
merge_request.merge_params['force_remove_source_branch'] = params.delete(:force_remove_source_branch)
|
merge_request.merge_params['force_remove_source_branch'] = params.delete(:force_remove_source_branch)
|
||||||
merge_request.head_pipeline = head_pipeline_for(merge_request)
|
|
||||||
|
|
||||||
create(merge_request)
|
create(merge_request)
|
||||||
end
|
end
|
||||||
|
@ -22,10 +21,16 @@ module MergeRequests
|
||||||
notification_service.new_merge_request(issuable, current_user)
|
notification_service.new_merge_request(issuable, current_user)
|
||||||
todo_service.new_merge_request(issuable, current_user)
|
todo_service.new_merge_request(issuable, current_user)
|
||||||
issuable.cache_merge_request_closes_issues!(current_user)
|
issuable.cache_merge_request_closes_issues!(current_user)
|
||||||
|
update_merge_requests_head_pipeline(issuable)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def update_merge_requests_head_pipeline(merge_request)
|
||||||
|
pipeline = head_pipeline_for(merge_request)
|
||||||
|
merge_request.update(head_pipeline_id: pipeline.id) if pipeline
|
||||||
|
end
|
||||||
|
|
||||||
def head_pipeline_for(merge_request)
|
def head_pipeline_for(merge_request)
|
||||||
return unless merge_request.source_project
|
return unless merge_request.source_project
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Fix an order of operations for CI connection error message in merge request
|
||||||
|
widget
|
||||||
|
merge_request: 13252
|
||||||
|
author:
|
|
@ -1,45 +1,88 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
feature 'Pipelines for Merge Requests', js: true do
|
feature 'Pipelines for Merge Requests', js: true do
|
||||||
given(:user) { create(:user) }
|
describe 'pipeline tab' do
|
||||||
given(:merge_request) { create(:merge_request) }
|
given(:user) { create(:user) }
|
||||||
given(:project) { merge_request.target_project }
|
given(:merge_request) { create(:merge_request) }
|
||||||
|
given(:project) { merge_request.target_project }
|
||||||
before do
|
|
||||||
project.team << [user, :master]
|
|
||||||
sign_in user
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with pipelines' do
|
|
||||||
let!(:pipeline) do
|
|
||||||
create(:ci_empty_pipeline,
|
|
||||||
project: merge_request.source_project,
|
|
||||||
ref: merge_request.source_branch,
|
|
||||||
sha: merge_request.diff_head_sha)
|
|
||||||
end
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
visit project_merge_request_path(project, merge_request)
|
project.team << [user, :master]
|
||||||
|
sign_in user
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'user visits merge request pipelines tab' do
|
context 'with pipelines' do
|
||||||
page.within('.merge-request-tabs') do
|
let!(:pipeline) do
|
||||||
click_link('Pipelines')
|
create(:ci_empty_pipeline,
|
||||||
|
project: merge_request.source_project,
|
||||||
|
ref: merge_request.source_branch,
|
||||||
|
sha: merge_request.diff_head_sha)
|
||||||
end
|
end
|
||||||
wait_for_requests
|
|
||||||
|
|
||||||
expect(page).to have_selector('.stage-cell')
|
before do
|
||||||
|
visit project_merge_request_path(project, merge_request)
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'user visits merge request pipelines tab' do
|
||||||
|
page.within('.merge-request-tabs') do
|
||||||
|
click_link('Pipelines')
|
||||||
|
end
|
||||||
|
wait_for_requests
|
||||||
|
|
||||||
|
expect(page).to have_selector('.stage-cell')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'without pipelines' do
|
||||||
|
before do
|
||||||
|
visit project_merge_request_path(project, merge_request)
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'user visits merge request page' do
|
||||||
|
page.within('.merge-request-tabs') do
|
||||||
|
expect(page).to have_no_link('Pipelines')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'without pipelines' do
|
describe 'race condition' do
|
||||||
before do
|
given(:project) { create(:project, :repository) }
|
||||||
visit project_merge_request_path(project, merge_request)
|
given(:user) { create(:user) }
|
||||||
|
given(:build_push_data) { { ref: 'feature', checkout_sha: TestEnv::BRANCH_SHA['feature'] } }
|
||||||
|
|
||||||
|
given(:merge_request_params) do
|
||||||
|
{ "source_branch" => "feature", "source_project_id" => project.id,
|
||||||
|
"target_branch" => "master", "target_project_id" => project.id, "title" => "A" }
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'user visits merge request page' do
|
background do
|
||||||
page.within('.merge-request-tabs') do
|
project.add_master(user)
|
||||||
expect(page).to have_no_link('Pipelines')
|
sign_in user
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when pipeline and merge request were created simultaneously' do
|
||||||
|
background do
|
||||||
|
stub_ci_pipeline_to_return_yaml_file
|
||||||
|
|
||||||
|
threads = []
|
||||||
|
|
||||||
|
threads << Thread.new do
|
||||||
|
@merge_request = MergeRequests::CreateService.new(project, user, merge_request_params).execute
|
||||||
|
end
|
||||||
|
|
||||||
|
threads << Thread.new do
|
||||||
|
@pipeline = Ci::CreatePipelineService.new(project, user, build_push_data).execute(:push)
|
||||||
|
end
|
||||||
|
|
||||||
|
threads.each { |thr| thr.join }
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'user sees pipeline in merge request widget' do
|
||||||
|
visit project_merge_request_path(project, @merge_request)
|
||||||
|
|
||||||
|
expect(page.find(".ci-widget")).to have_content(TestEnv::BRANCH_SHA['feature'])
|
||||||
|
expect(page.find(".ci-widget")).to have_content("##{@pipeline.id}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue