gitlab-org--gitlab-foss/spec/features/merge_request/user_merges_when_pipeline_s...

191 lines
5.8 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'spec_helper'
2015-11-24 13:59:02 +00:00
RSpec.describe 'Merge request > User merges when pipeline succeeds', :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:merge_request) do
create(:merge_request_with_diffs, source_project: project,
author: user,
title: 'Bug NS-04',
merge_params: { force_remove_source_branch: '1' })
end
let(:pipeline) do
create(:ci_pipeline, project: project,
sha: merge_request.diff_head_sha,
ref: merge_request.source_branch,
head_pipeline_of: merge_request)
2015-11-24 13:59:02 +00:00
end
2017-03-22 19:36:14 +00:00
before do
project.add_maintainer(user)
2017-03-22 19:36:14 +00:00
end
context 'when there is active pipeline for merge request' do
2015-12-07 10:54:07 +00:00
before do
create(:ci_build, pipeline: pipeline)
sign_in(user)
visit project_merge_request_path(project, merge_request)
2015-11-24 13:59:02 +00:00
end
describe 'enabling Merge when pipeline succeeds' do
shared_examples 'Merge when pipeline succeeds activator' do
it 'activates the Merge when pipeline succeeds feature' do
click_button "Merge when pipeline succeeds"
2017-08-07 02:29:37 +00:00
expect(page).to have_content "Set by #{user.name} to be merged automatically when the pipeline succeeds"
expect(page).to have_content "The source branch will not be deleted"
2017-05-09 04:15:34 +00:00
expect(page).to have_selector ".js-cancel-auto-merge"
visit project_merge_request_path(project, merge_request) # Needed to refresh the page
expect(page).to have_content /enabled an automatic merge when the pipeline for \h{8} succeeds/i
end
2015-11-24 13:59:02 +00:00
end
context "when enabled immediately" do
it_behaves_like 'Merge when pipeline succeeds activator'
end
context 'when enabled after pipeline status changed', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/258667' do
before do
pipeline.run!
2015-11-24 13:59:02 +00:00
# We depend on merge request widget being reloaded
# so we have to wait for asynchronous call to reload it
# and have_content expectation handles that.
#
expect(page).to have_content "Pipeline ##{pipeline.id} running"
end
it_behaves_like 'Merge when pipeline succeeds activator'
end
context 'when enabled after it was previously canceled' do
before do
click_button "Merge when pipeline succeeds"
click_link "Cancel"
wait_for_requests
expect(page).to have_content 'Merge when pipeline succeeds'
end
it_behaves_like 'Merge when pipeline succeeds activator'
end
2015-12-03 09:27:34 +00:00
context 'when it was enabled and then canceled' do
let(:merge_request) do
create(:merge_request_with_diffs,
:merge_when_pipeline_succeeds,
source_project: project,
title: 'Bug NS-04',
author: user,
merge_user: user)
end
before do
merge_request.merge_params['force_remove_source_branch'] = '0'
merge_request.save!
click_link "Cancel"
end
it_behaves_like 'Merge when pipeline succeeds activator'
2015-11-24 13:59:02 +00:00
end
end
end
context 'when merge when pipeline succeeds is enabled' do
2015-12-03 09:27:34 +00:00
let(:merge_request) do
create(:merge_request_with_diffs, :simple, :merge_when_pipeline_succeeds,
source_project: project,
author: user,
merge_user: user,
title: 'MepMep')
2015-12-03 09:27:34 +00:00
end
let!(:build) do
create(:ci_build, pipeline: pipeline)
end
2015-12-07 10:54:07 +00:00
2015-11-24 13:59:02 +00:00
before do
sign_in user
visit project_merge_request_path(project, merge_request)
2015-11-24 13:59:02 +00:00
end
it 'allows to cancel the automatic merge' do
click_link "Cancel"
2015-11-24 13:59:02 +00:00
expect(page).to have_button "Merge when pipeline succeeds"
2015-12-03 09:27:34 +00:00
refresh
makes system notes less intrusive to a conversation adds dicussion icon and color change in system note links adds discussion icons and sticky note icon for other system notes for now fixes scss lint error adds faded commit lists hides first paragraph in commit list box css tweak for commit list system notes adds commit-list toggle functionality, css tweaks and css classnames more readable small css fix in header. makes links bold in system note renames class no-shade to hide-shade adds entry for this merge request in changelog removes commented line removes the avatar-icon from discussion header minor css tweaks to make the commit list alignment with header text uses monospaced font to make the commit list lined up with all removes icon from system note and align bullet list resolves scss lint warings adds helper function to extract system note message from first p tag adds helper functions to check commit list count and haml cleanup adds changelog entry under 8.14 adds changelog entry with changelog cli removes helper and regex and makes commit list li count using JS makes link in system note normal brakeman build failure resolved fixing rspec test based on new design for discussion shows system note in lowercase removes extra spaces from comments adds code commenting for functions adds semi-colon in some lines fixes rspec given when merge build success removes commented codes rewrite changelog yml file moves isMetaKey to common utils file fixes some indentation issues removes unnecessary variables and resolves some discussions replaces jQuery parent function with siblings fixes scss issues and variable spelling mistake uses constant rather using hardcoded number for visible li count in long commit list makes system note header all lowercase uses color variables and adjust gradient a little some minor changes for adding css classes renames functions name for readability changes changelog title minor scss newline changes makes system note less intrusive to a conversation
2016-10-08 06:50:28 +00:00
expect(page).to have_content "canceled the automatic merge"
2015-11-24 13:59:02 +00:00
end
it 'allows to delete source branch' do
click_link "Delete source branch"
expect(page).to have_content "The source branch will be deleted"
end
context 'when pipeline succeeds' do
before do
build.success
refresh
end
it 'merges merge request', :sidekiq_might_not_need_inline do
expect(page).to have_content 'The changes were merged'
expect(merge_request.reload).to be_merged
end
end
context 'view merge request with MWPS enabled but automatically merge fails' do
before do
merge_request.update!(
merge_user: merge_request.author,
merge_error: 'Something went wrong'
)
refresh
end
it 'shows information about the merge error' do
# Wait for the `ci_status` and `merge_check` requests
wait_for_requests
page.within('.mr-section-container') do
expect(page).to have_content('Something went wrong. Try again.')
end
end
end
context 'view merge request with MWPS enabled but automatically merge fails' do
before do
merge_request.update!(
merge_user: merge_request.author,
merge_error: 'Something went wrong.'
)
refresh
end
it 'shows information about the merge error' do
# Wait for the `ci_status` and `merge_check` requests
wait_for_requests
page.within('.mr-section-container') do
expect(page).to have_content('Something went wrong. Try again.')
end
end
end
2015-11-24 13:59:02 +00:00
end
context 'when pipeline is not active' do
it 'does not allow to enable merge when pipeline succeeds' do
visit project_merge_request_path(project, merge_request)
expect(page).not_to have_link 'Merge when pipeline succeeds'
2015-11-24 13:59:02 +00:00
end
end
end