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

110 lines
3.4 KiB
Ruby
Raw Normal View History

2015-11-24 13:59:02 +00:00
require 'spec_helper'
feature 'Merge When Pipeline Succeeds', :feature, :js do
2015-11-24 13:59:02 +00:00
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
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')
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)
2015-11-24 13:59:02 +00:00
end
before { project.team << [user, :master] }
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
2015-11-24 13:59:02 +00:00
login_as user
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
context "Merge When Pipeline Succeeds enabled" do
2015-11-24 13:59:02 +00:00
before do
click_button "Merge When Pipeline Succeeds"
2015-11-24 13:59:02 +00:00
end
it 'activates Merge When Pipeline Succeeds feature' do
2015-11-24 13:59:02 +00:00
expect(page).to have_link "Cancel Automatic Merge"
expect(page).to have_content "Set by #{user.name} to be merged automatically when the pipeline succeeds."
2015-11-24 13:59:02 +00:00
expect(page).to have_content "The source branch will not be removed."
2015-12-03 09:27:34 +00:00
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
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, source_project: project,
author: user,
merge_user: user,
title: 'MepMep',
merge_when_build_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
login_as user
visit_merge_request(merge_request)
end
it 'allows to cancel the automatic merge' do
2015-11-24 13:59:02 +00:00
click_link "Cancel Automatic Merge"
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
it "allows the user to remove the source branch" do
expect(page).to have_link "Remove Source Branch When Merged"
2015-12-03 09:27:34 +00:00
click_link "Remove Source Branch When Merged"
expect(page).to have_content "The source branch will be removed"
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 namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request)
end
end