debian-mirror-gitlab/spec/features/merge_request/user_sees_pipelines_spec.rb

136 lines
4 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2016-09-13 17:45:13 +05:30
2018-03-17 18:26:18 +05:30
describe 'Merge request > User sees pipelines', :js do
2017-09-10 17:25:29 +05:30
describe 'pipeline tab' do
2018-03-17 18:26:18 +05:30
let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.target_project }
let(:user) { project.creator }
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
before do
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2018-03-17 18:26:18 +05:30
sign_in(user)
2016-09-13 17:45:13 +05:30
end
2017-09-10 17:25:29 +05:30
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
2018-03-17 18:26:18 +05:30
merge_request.update_attribute(:head_pipeline_id, pipeline.id)
2017-09-10 17:25:29 +05:30
end
2018-03-17 18:26:18 +05:30
it 'user visits merge request pipelines tab' do
visit project_merge_request_path(project, merge_request)
expect(page.find('.ci-widget')).to have_content('pending')
2017-09-10 17:25:29 +05:30
page.within('.merge-request-tabs') do
click_link('Pipelines')
end
wait_for_requests
expect(page).to have_selector('.stage-cell')
end
2018-03-17 18:26:18 +05:30
it 'pipeline sha does not equal last commit sha' do
pipeline.update_attribute(:sha, '19e2e9b4ef76b422ce1154af39a91323ccc57434')
visit project_merge_request_path(project, merge_request)
wait_for_requests
2018-12-13 13:39:08 +05:30
expect(page.find('.ci-widget')).to have_text("Could not retrieve the pipeline status. For troubleshooting steps, read the documentation.")
2018-03-17 18:26:18 +05:30
end
2019-12-04 20:38:33 +05:30
context 'with a detached merge request pipeline' do
let(:merge_request) { create(:merge_request, :with_detached_merge_request_pipeline) }
it 'displays the Run Pipeline button' do
visit project_merge_request_path(project, merge_request)
page.within('.merge-request-tabs') do
click_link('Pipelines')
end
wait_for_requests
expect(page.find('.js-run-mr-pipeline')).to have_text('Run Pipeline')
end
end
context 'with a merged results pipeline' do
let(:merge_request) { create(:merge_request, :with_merge_request_pipeline) }
it 'displays the Run Pipeline button' do
visit project_merge_request_path(project, merge_request)
page.within('.merge-request-tabs') do
click_link('Pipelines')
end
wait_for_requests
expect(page.find('.js-run-mr-pipeline')).to have_text('Run Pipeline')
end
end
2016-09-13 17:45:13 +05:30
end
2017-09-10 17:25:29 +05:30
context 'without pipelines' do
before do
visit project_merge_request_path(project, merge_request)
2016-09-13 17:45:13 +05:30
end
2018-03-17 18:26:18 +05:30
it 'user visits merge request page' do
2017-09-10 17:25:29 +05:30
page.within('.merge-request-tabs') do
expect(page).to have_no_link('Pipelines')
end
end
2016-09-13 17:45:13 +05:30
end
end
2017-09-10 17:25:29 +05:30
describe 'race condition' do
2018-03-17 18:26:18 +05:30
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:build_push_data) { { ref: 'feature', checkout_sha: TestEnv::BRANCH_SHA['feature'] } }
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
let(:merge_request_params) do
2017-09-10 17:25:29 +05:30
{ "source_branch" => "feature", "source_project_id" => project.id,
"target_branch" => "master", "target_project_id" => project.id, "title" => "A" }
end
2018-03-17 18:26:18 +05:30
before do
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2017-09-10 17:25:29 +05:30
sign_in user
2016-09-13 17:45:13 +05:30
end
2017-09-10 17:25:29 +05:30
context 'when pipeline and merge request were created simultaneously' do
2018-03-17 18:26:18 +05:30
before do
2017-09-10 17:25:29 +05:30
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
2019-12-26 22:10:19 +05:30
it 'user sees pipeline in merge request widget', :sidekiq_might_not_need_inline do
2017-09-10 17:25:29 +05:30
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}")
2016-09-13 17:45:13 +05:30
end
end
end
end