summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-08-04 21:26:24 +0000
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2017-08-11 21:02:33 +0100
commit14936d0c34b50acb49dedc51fb8c8fe23a2dac1a (patch)
treefb4d80ea4cf53359eb22e3e15ff549cab9f0f354 /spec
parent97bd335109bb7121842fb8c269dbae8cbe7c8bf7 (diff)
downloadgitlab-ce-14936d0c34b50acb49dedc51fb8c8fe23a2dac1a.tar.gz
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
Diffstat (limited to 'spec')
-rw-r--r--spec/features/merge_requests/pipelines_spec.rb97
1 files changed, 70 insertions, 27 deletions
diff --git a/spec/features/merge_requests/pipelines_spec.rb b/spec/features/merge_requests/pipelines_spec.rb
index 837366ced3c..fc4d9d0e479 100644
--- a/spec/features/merge_requests/pipelines_spec.rb
+++ b/spec/features/merge_requests/pipelines_spec.rb
@@ -1,45 +1,88 @@
require 'spec_helper'
feature 'Pipelines for Merge Requests', feature: true, js: true do
- given(:user) { create(:user) }
- given(:merge_request) { create(:merge_request) }
- given(:project) { merge_request.target_project }
+ describe 'pipeline tab' do
+ given(:user) { create(:user) }
+ 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)
+ before do
+ project.team << [user, :master]
+ sign_in user
end
- before do
- visit project_merge_request_path(project, merge_request)
+ 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
+ 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
- scenario 'user visits merge request pipelines tab' do
- page.within('.merge-request-tabs') do
- click_link('Pipelines')
+ context 'without pipelines' do
+ before do
+ visit project_merge_request_path(project, merge_request)
end
- wait_for_requests
- expect(page).to have_selector('.stage-cell')
+ scenario 'user visits merge request page' do
+ page.within('.merge-request-tabs') do
+ expect(page).to have_no_link('Pipelines')
+ end
+ end
end
end
- context 'without pipelines' do
- before do
- visit project_merge_request_path(project, merge_request)
+ describe 'race condition' do
+ given(:project) { create(:project, :repository) }
+ 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
+
+ background do
+ project.add_master(user)
+ sign_in user
end
- scenario 'user visits merge request page' do
- page.within('.merge-request-tabs') do
- expect(page).to have_no_link('Pipelines')
+ 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