summaryrefslogtreecommitdiff
path: root/spec/features/merge_request
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/merge_request')
-rw-r--r--spec/features/merge_request/user_customizes_merge_commit_message_spec.rb51
-rw-r--r--spec/features/merge_request/user_expands_diff_spec.rb1
-rw-r--r--spec/features/merge_request/user_invites_from_a_comment_spec.rb25
-rw-r--r--spec/features/merge_request/user_posts_diff_notes_spec.rb7
-rw-r--r--spec/features/merge_request/user_resolves_wip_mr_spec.rb4
-rw-r--r--spec/features/merge_request/user_sees_wip_help_message_spec.rb4
-rw-r--r--spec/features/merge_request/user_squashes_merge_request_spec.rb38
-rw-r--r--spec/features/merge_request/user_views_open_merge_request_spec.rb2
8 files changed, 69 insertions, 63 deletions
diff --git a/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb b/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb
index 06795344c5c..67a232607cd 100644
--- a/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb
+++ b/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb
@@ -7,19 +7,26 @@ RSpec.describe 'Merge request < User customizes merge commit message', :js do
let(:user) { project.creator }
let(:issue_1) { create(:issue, project: project)}
let(:issue_2) { create(:issue, project: project)}
+ let(:source_branch) { 'csv' }
+ let(:target_branch) { 'master' }
+ let(:squash) { false }
let(:merge_request) do
create(
:merge_request,
- :simple,
source_project: project,
- description: "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}"
+ target_project: project,
+ source_branch: source_branch,
+ target_branch: target_branch,
+ description: "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}",
+ squash: squash
)
end
- let(:textbox) { page.find(:css, '#merge-message-edit', visible: false) }
- let(:default_message) do
+ let(:merge_textbox) { page.find(:css, '#merge-message-edit', visible: false) }
+ let(:squash_textbox) { page.find(:css, '#squash-message-edit', visible: false) }
+ let(:default_merge_commit_message) do
[
- "Merge branch 'feature' into 'master'",
+ "Merge branch '#{source_branch}' into '#{target_branch}'",
merge_request.title,
"Closes #{issue_1.to_reference} and #{issue_2.to_reference}",
"See merge request #{merge_request.to_reference(full: true)}"
@@ -35,8 +42,8 @@ RSpec.describe 'Merge request < User customizes merge commit message', :js do
it 'has commit message without description' do
expect(page).not_to have_selector('#merge-message-edit')
first('.js-mr-widget-commits-count').click
- expect(textbox).to be_visible
- expect(textbox.value).to eq(default_message)
+ expect(merge_textbox).to be_visible
+ expect(merge_textbox.value).to eq(default_merge_commit_message)
end
context 'when target project has merge commit template set' do
@@ -45,8 +52,34 @@ RSpec.describe 'Merge request < User customizes merge commit message', :js do
it 'uses merge commit template' do
expect(page).not_to have_selector('#merge-message-edit')
first('.js-mr-widget-commits-count').click
- expect(textbox).to be_visible
- expect(textbox.value).to eq(merge_request.title)
+ expect(merge_textbox).to be_visible
+ expect(merge_textbox.value).to eq(merge_request.title)
+ end
+ end
+
+ context 'when squash is performed' do
+ let(:squash) { true }
+
+ it 'has default message with merge request title' do
+ expect(page).not_to have_selector('#squash-message-edit')
+ first('.js-mr-widget-commits-count').click
+ expect(squash_textbox).to be_visible
+ expect(merge_textbox).to be_visible
+ expect(squash_textbox.value).to eq(merge_request.title)
+ expect(merge_textbox.value).to eq(default_merge_commit_message)
+ end
+
+ context 'when target project has squash commit template set' do
+ let(:project) { create(:project, :public, :repository, squash_commit_template: '%{description}') }
+
+ it 'uses squash commit template' do
+ expect(page).not_to have_selector('#squash-message-edit')
+ first('.js-mr-widget-commits-count').click
+ expect(squash_textbox).to be_visible
+ expect(merge_textbox).to be_visible
+ expect(squash_textbox.value).to eq(merge_request.description)
+ expect(merge_textbox.value).to eq(default_merge_commit_message)
+ end
end
end
end
diff --git a/spec/features/merge_request/user_expands_diff_spec.rb b/spec/features/merge_request/user_expands_diff_spec.rb
index 09c5897f102..52554f11d28 100644
--- a/spec/features/merge_request/user_expands_diff_spec.rb
+++ b/spec/features/merge_request/user_expands_diff_spec.rb
@@ -7,7 +7,6 @@ RSpec.describe 'User expands diff', :js do
let(:merge_request) { create(:merge_request, source_branch: 'expand-collapse-files', source_project: project, target_project: project) }
before do
- stub_feature_flags(increased_diff_limits: false)
allow(Gitlab::CurrentSettings).to receive(:diff_max_patch_bytes).and_return(100.kilobytes)
visit(diffs_project_merge_request_path(project, merge_request))
diff --git a/spec/features/merge_request/user_invites_from_a_comment_spec.rb b/spec/features/merge_request/user_invites_from_a_comment_spec.rb
deleted file mode 100644
index 79865094fd0..00000000000
--- a/spec/features/merge_request/user_invites_from_a_comment_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# frozen_string_literal: true
-
-require "spec_helper"
-
-RSpec.describe "User invites from a comment", :js do
- let_it_be(:project) { create(:project, :public, :repository) }
- let_it_be(:merge_request) { create(:merge_request, source_project: project) }
- let_it_be(:user) { project.owner }
-
- before do
- sign_in(user)
- end
-
- it "launches the invite modal from invite link on a comment" do
- stub_experiments(invite_members_in_comment: :invite_member_link)
-
- visit project_merge_request_path(project, merge_request)
-
- page.within(".new-note") do
- click_button 'Invite Member'
- end
-
- expect(page).to have_content("You're inviting members to the")
- end
-end
diff --git a/spec/features/merge_request/user_posts_diff_notes_spec.rb b/spec/features/merge_request/user_posts_diff_notes_spec.rb
index 79e46e69157..9e314e18563 100644
--- a/spec/features/merge_request/user_posts_diff_notes_spec.rb
+++ b/spec/features/merge_request/user_posts_diff_notes_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe 'Merge request > User posts diff notes', :js do
include MergeRequestDiffHelpers
+ include Spec::Support::Helpers::ModalHelpers
let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.source_project }
@@ -238,10 +239,8 @@ RSpec.describe 'Merge request > User posts diff notes', :js do
def should_allow_dismissing_a_comment(line_holder, diff_side = nil)
write_comment_on_line(line_holder, diff_side)
- find('.js-close-discussion-note-form').click
-
- page.within('.modal') do
- click_button 'OK'
+ accept_gl_confirm(s_('Notes|Are you sure you want to cancel creating this comment?')) do
+ find('.js-close-discussion-note-form').click
end
assert_comment_dismissal(line_holder)
diff --git a/spec/features/merge_request/user_resolves_wip_mr_spec.rb b/spec/features/merge_request/user_resolves_wip_mr_spec.rb
index 93b14279a06..fd405855cf8 100644
--- a/spec/features/merge_request/user_resolves_wip_mr_spec.rb
+++ b/spec/features/merge_request/user_resolves_wip_mr_spec.rb
@@ -33,7 +33,7 @@ RSpec.describe 'Merge request > User resolves Work in Progress', :js do
it 'retains merge request data after clicking Resolve WIP status' do
expect(page.find('.ci-widget-content')).to have_content("Pipeline ##{pipeline.id}")
- expect(page).to have_content "This merge request is still a draft."
+ expect(page).to have_content "Merge blocked: merge request must be marked as ready. It's still marked as draft."
page.within('.mr-state-widget') do
click_button('Mark as ready')
@@ -45,7 +45,7 @@ RSpec.describe 'Merge request > User resolves Work in Progress', :js do
# merge request widget refreshes, which masks missing elements
# that should already be present.
expect(page.find('.ci-widget-content', wait: 0)).to have_content("Pipeline ##{pipeline.id}")
- expect(page).not_to have_content('This merge request is still a draft.')
+ expect(page).not_to have_content("Merge blocked: merge request must be marked as ready. It's still marked as draft.")
end
end
end
diff --git a/spec/features/merge_request/user_sees_wip_help_message_spec.rb b/spec/features/merge_request/user_sees_wip_help_message_spec.rb
index 0a6a3d82ee0..d33e54f2e3d 100644
--- a/spec/features/merge_request/user_sees_wip_help_message_spec.rb
+++ b/spec/features/merge_request/user_sees_wip_help_message_spec.rb
@@ -46,8 +46,8 @@ RSpec.describe 'Merge request > User sees draft help message' do
'It looks like you have some draft commits in this branch'
)
expect(page).to have_text(
- "Start the title with Draft: to prevent a merge request that is a \
-work in progress from being merged before it's ready."
+ "Start the title with Draft: to prevent a merge request draft \
+from merging before it's ready."
)
end
end
diff --git a/spec/features/merge_request/user_squashes_merge_request_spec.rb b/spec/features/merge_request/user_squashes_merge_request_spec.rb
index 15f59c0d7bc..2a48657ac4f 100644
--- a/spec/features/merge_request/user_squashes_merge_request_spec.rb
+++ b/spec/features/merge_request/user_squashes_merge_request_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe 'User squashes a merge request', :js do
committer_name: user.name)
merge_commit = an_object_having_attributes(sha: a_string_matching(/\h{40}/),
- message: a_string_starting_with("Merge branch 'csv' into 'master'"),
+ message: a_string_starting_with("Merge branch '#{source_branch}' into 'master'"),
author_name: user.name,
committer_name: user.name)
@@ -57,34 +57,34 @@ RSpec.describe 'User squashes a merge request', :js do
end
context 'when the MR has only one commit' do
- let(:source_branch) { 'master' }
- let(:target_branch) { 'branch-merged' }
- let(:protected_source_branch) { true }
+ let(:source_branch) { 'feature' }
+ let(:target_branch) { 'master' }
let(:source_sha) { project.commit(source_branch).sha }
let(:target_sha) { project.commit(target_branch).sha }
before do
- merge_request = create(:merge_request, source_project: project, target_project: project, source_branch: source_branch, target_branch: target_branch, squash: true)
-
- visit project_merge_request_path(project, merge_request)
+ visit project_new_merge_request_path(project, merge_request: { target_branch: target_branch, source_branch: source_branch })
+ check 'merge_request[squash]'
+ click_on 'Create merge request'
+ wait_for_requests
end
- it 'accepts the merge request without issuing a squash request', :sidekiq_inline do
- expect_next_instance_of(Gitlab::GitalyClient::OperationService) do |instance|
- expect(instance).not_to receive(:user_squash)
+ context 'when squash message differs from existing commit message' do
+ before do
+ accept_mr
end
- expect(project.repository.ancestor?(source_branch, target_branch)).to be_falsey
- expect(page).not_to have_field('squash')
-
- accept_mr
-
- expect(page).to have_content('Merged')
+ include_examples 'squash'
+ end
- latest_target_commits = project.repository.commits_between(source_sha, target_sha).map(&:raw)
+ context 'when squash message is the same as existing commit message' do
+ before do
+ click_button("Modify commit messages")
+ fill_in('Squash commit message', with: project.commit(source_branch).safe_message)
+ accept_mr
+ end
- expect(latest_target_commits.count).to eq(1)
- expect(project.repository.ancestor?(source_branch, target_branch)).to be_truthy
+ include_examples 'no squash'
end
end
diff --git a/spec/features/merge_request/user_views_open_merge_request_spec.rb b/spec/features/merge_request/user_views_open_merge_request_spec.rb
index 073706cf9d8..b5a973a53c0 100644
--- a/spec/features/merge_request/user_views_open_merge_request_spec.rb
+++ b/spec/features/merge_request/user_views_open_merge_request_spec.rb
@@ -20,7 +20,7 @@ RSpec.describe 'User views an open merge request' do
# Work around a weird Capybara behavior where calling `parent` on a node
# returns the whole document, not the node's actual parent element
- expect(find(:xpath, "#{node.path}/..").text).to eq(merge_request.description[2..-1])
+ expect(find(:xpath, "#{node.path}/..").text).to eq(merge_request.description[2..])
expect(page).to have_content(merge_request.title)
end