gitlab-org--gitlab-foss/spec/features/merge_requests/merge_when_pipeline_succeed...

161 lines
5.2 KiB
Ruby
Raw Normal View History

2015-11-24 13:59:02 +00:00
require 'spec_helper'
feature 'Merge When Pipeline Succeeds', :js do
2015-11-24 13:59:02 +00:00
let(:user) { create(:user) }
let(:project) { create(:project, :public, :repository) }
2015-11-24 13:59:02 +00:00
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
2015-11-24 13:59:02 +00:00
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_master(user)
end
context 'when there is active pipeline for merge request' do
background do
create(:ci_build, pipeline: pipeline)
end
2015-11-24 13:59:02 +00:00
2015-12-07 10:54:07 +00:00
before do
sign_in user
2015-11-24 13:59:02 +00:00
visit_merge_request(merge_request)
end
it 'displays the Merge when pipeline succeeds button' do
expect(page).to have_button "Merge when pipeline succeeds"
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 removed"
2017-05-09 04:15:34 +00:00
expect(page).to have_selector ".js-cancel-auto-merge"
visit_merge_request(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' 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 automatic merge"
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,
merge_params: { force_remove_source_branch: '1' })
end
before do
click_link "Cancel automatic merge"
end
it_behaves_like 'Merge when pipeline succeeds activator'
2015-11-24 13:59:02 +00:00
end
end
2017-04-11 05:01:03 +00:00
describe 'enabling Merge when pipeline succeeds via dropdown' do
it 'activates the Merge when pipeline succeeds feature' do
2017-08-07 02:29:37 +00:00
find('.js-merge-moment').click
2017-05-09 04:15:34 +00:00
click_link 'Merge when pipeline succeeds'
2017-04-11 05:01:03 +00:00
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 removed"
2017-04-11 05:01:03 +00:00
expect(page).to have_link "Cancel automatic merge"
end
end
2015-11-24 13:59:02 +00:00
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, source_project: project,
author: user,
merge_user: user,
title: 'MepMep',
merge_when_pipeline_succeeds: true)
2015-12-03 09:27:34 +00:00
end
2015-11-24 13:59:02 +00:00
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
2015-11-24 13:59:02 +00:00
visit_merge_request(merge_request)
end
it 'allows to cancel the automatic merge' do
click_link "Cancel automatic merge"
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
visit_merge_request(merge_request) # refresh the page
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
context 'when pipeline succeeds' do
background { build.success }
it 'merges merge request' do
visit_merge_request(merge_request) # refresh the page
expect(page).to have_content 'The changes were merged'
expect(merge_request.reload).to be_merged
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
2015-11-24 13:59:02 +00:00
visit_merge_request(merge_request)
expect(page).not_to have_link 'Merge when pipeline succeeds'
2015-11-24 13:59:02 +00:00
end
end
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
2015-11-24 13:59:02 +00:00
def visit_merge_request(merge_request)
visit project_merge_request_path(merge_request.project, merge_request)
2015-11-24 13:59:02 +00:00
end
end