summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-08-01 20:03:07 +0200
committerRémy Coutable <remy@rymai.me>2018-01-18 15:07:57 +0100
commit799cd471099e032a60fbdb1ba6841e617f6c122f (patch)
treee18e25e7ec82f9fb35bad04890e57c21a69097af
parent50a649530a53a04d2044f9e4c5502586a7ed0c59 (diff)
downloadgitlab-ce-799cd471099e032a60fbdb1ba6841e617f6c122f.tar.gz
Improve MR feature specs and reduce duplicationrc/improve-mr-feature-specs
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r--spec/features/merge_request/user_assigns_themselves_spec.rb49
-rw-r--r--spec/features/merge_request/user_awards_emoji_spec.rb (renamed from spec/features/merge_requests/award_spec.rb)4
-rw-r--r--spec/features/merge_request/user_cherry_picks_spec.rb (renamed from spec/features/merge_requests/cherry_pick_spec.rb)22
-rw-r--r--spec/features/merge_request/user_creates_image_diff_notes_spec.rb (renamed from spec/features/merge_requests/image_diff_notes_spec.rb)39
-rw-r--r--spec/features/merge_request/user_creates_mr_spec.rb31
-rw-r--r--spec/features/merge_request/user_customizes_merge_commit_message_spec.rb (renamed from spec/features/merge_requests/merge_commit_message_toggle_spec.rb)15
-rw-r--r--spec/features/merge_request/user_edits_mr_spec.rb11
-rw-r--r--spec/features/merge_request/user_locks_discussion_spec.rb (renamed from spec/features/merge_requests/discussion_lock_spec.rb)6
-rw-r--r--spec/features/merge_request/user_merges_immediately_spec.rb (renamed from spec/features/merge_requests/merge_immediately_with_pipeline_spec.rb)22
-rw-r--r--spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb (renamed from spec/features/merge_requests/only_allow_merge_if_build_succeeds_spec.rb)51
-rw-r--r--spec/features/merge_request/user_merges_when_pipeline_succeeds_spec.rb (renamed from spec/features/merge_requests/merge_when_pipeline_succeeds_spec.rb)82
-rw-r--r--spec/features/merge_request/user_posts_diff_notes_spec.rb (renamed from spec/features/merge_requests/user_posts_diff_notes_spec.rb)15
-rw-r--r--spec/features/merge_request/user_posts_notes_spec.rb (renamed from spec/features/merge_requests/user_posts_notes_spec.rb)8
-rw-r--r--spec/features/merge_request/user_resolves_conflicts_spec.rb (renamed from spec/features/merge_requests/conflicts_spec.rb)7
-rw-r--r--spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb (renamed from spec/features/merge_requests/diff_notes_resolve_spec.rb)31
-rw-r--r--spec/features/merge_request/user_resolves_outdated_diff_discussions_spec.rb (renamed from spec/features/merge_requests/resolve_outdated_diff_discussions.rb)2
-rw-r--r--spec/features/merge_request/user_scrolls_to_note_on_load_spec.rb26
-rw-r--r--spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb (renamed from spec/features/merge_requests/diff_notes_avatars_spec.rb)8
-rw-r--r--spec/features/merge_request/user_sees_closing_issues_message_spec.rb (renamed from spec/features/merge_requests/closes_issues_spec.rb)10
-rw-r--r--spec/features/merge_request/user_sees_deleted_target_branch_spec.rb22
-rw-r--r--spec/features/merge_request/user_sees_deployment_widget_spec.rb56
-rw-r--r--spec/features/merge_request/user_sees_diff_spec.rb (renamed from spec/features/merge_requests/diffs_spec.rb)4
-rw-r--r--spec/features/merge_request/user_sees_discussions_spec.rb (renamed from spec/features/merge_requests/discussion_spec.rb)19
-rw-r--r--spec/features/merge_request/user_sees_empty_state_spec.rb30
-rw-r--r--spec/features/merge_request/user_sees_merge_button_depending_on_unresolved_discussions_spec.rb (renamed from spec/features/merge_requests/check_if_mergeable_with_unresolved_discussions_spec.rb)24
-rw-r--r--spec/features/merge_request/user_sees_merge_widget_spec.rb (renamed from spec/features/merge_requests/widget_spec.rb)4
-rw-r--r--spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb (renamed from spec/features/merge_requests/mini_pipeline_graph_spec.rb)28
-rw-r--r--spec/features/merge_request/user_sees_mr_from_deleted_forked_project_spec.rb24
-rw-r--r--spec/features/merge_request/user_sees_mr_with_deleted_source_branch_spec.rb (renamed from spec/features/merge_requests/deleted_source_branch_spec.rb)20
-rw-r--r--spec/features/merge_request/user_sees_notes_from_forked_project_spec.rb35
-rw-r--r--spec/features/merge_request/user_sees_pipelines_from_forked_project_spec.rb34
-rw-r--r--spec/features/merge_request/user_sees_pipelines_spec.rb (renamed from spec/features/merge_requests/pipelines_spec.rb)32
-rw-r--r--spec/features/merge_request/user_sees_system_notes_spec.rb (renamed from spec/features/merge_requests/user_sees_system_notes_spec.rb)6
-rw-r--r--spec/features/merge_request/user_sees_versions_spec.rb (renamed from spec/features/merge_requests/versions_spec.rb)45
-rw-r--r--spec/features/merge_request/user_sees_wip_help_message_spec.rb (renamed from spec/features/merge_requests/wip_message_spec.rb)8
-rw-r--r--spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb (renamed from spec/features/merge_requests/create_new_mr_spec.rb)9
-rw-r--r--spec/features/merge_request/user_toggles_whitespace_changes_spec.rb (renamed from spec/features/merge_requests/toggle_whitespace_changes_spec.rb)13
-rw-r--r--spec/features/merge_request/user_uses_slash_commands_spec.rb (renamed from spec/features/merge_requests/user_uses_slash_commands_spec.rb)19
-rw-r--r--spec/features/merge_requests/assign_issues_spec.rb51
-rw-r--r--spec/features/merge_requests/create_new_mr_from_fork_spec.rb89
-rw-r--r--spec/features/merge_requests/created_from_fork_spec.rb94
-rw-r--r--spec/features/merge_requests/edit_mr_spec.rb73
-rw-r--r--spec/features/merge_requests/filter_by_labels_spec.rb93
-rw-r--r--spec/features/merge_requests/filter_by_milestone_spec.rb97
-rw-r--r--spec/features/merge_requests/filter_merge_requests_spec.rb337
-rw-r--r--spec/features/merge_requests/filters_generic_behavior_spec.rb81
-rw-r--r--spec/features/merge_requests/form_spec.rb301
-rw-r--r--spec/features/merge_requests/reset_filters_spec.rb136
-rw-r--r--spec/features/merge_requests/target_branch_spec.rb33
-rw-r--r--spec/features/merge_requests/toggler_behavior_spec.rb28
-rw-r--r--spec/features/merge_requests/user_filters_by_assignees_spec.rb36
-rw-r--r--spec/features/merge_requests/user_filters_by_labels_spec.rb49
-rw-r--r--spec/features/merge_requests/user_filters_by_milestones_spec.rb62
-rw-r--r--spec/features/merge_requests/user_filters_by_multiple_criteria_spec.rb38
-rw-r--r--spec/features/merge_requests/user_lists_merge_requests_spec.rb4
-rw-r--r--spec/features/merge_requests/user_mass_updates_spec.rb (renamed from spec/features/merge_requests/update_merge_requests_spec.rb)20
-rw-r--r--spec/features/merge_requests/widget_deployments_spec.rb59
-rw-r--r--spec/features/projects/merge_requests/list_spec.rb44
-rw-r--r--spec/support/shared_examples/features/creatable_merge_request_shared_examples.rb99
-rw-r--r--spec/support/shared_examples/features/editable_merge_request_shared_examples.rb140
60 files changed, 1087 insertions, 1748 deletions
diff --git a/spec/features/merge_request/user_assigns_themselves_spec.rb b/spec/features/merge_request/user_assigns_themselves_spec.rb
new file mode 100644
index 00000000000..b6b38186a22
--- /dev/null
+++ b/spec/features/merge_request/user_assigns_themselves_spec.rb
@@ -0,0 +1,49 @@
+require 'rails_helper'
+
+describe 'Merge request > User assigns themselves' do
+ let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
+ let(:issue1) { create(:issue, project: project) }
+ let(:issue2) { create(:issue, project: project) }
+ let(:merge_request) { create(:merge_request, :simple, source_project: project, author: user, description: "fixes #{issue1.to_reference} and #{issue2.to_reference}") }
+
+ context 'logged in as a member of the project' do
+ before do
+ sign_in(user)
+ visit project_merge_request_path(project, merge_request)
+ end
+
+ it 'updates related issues', :js do
+ click_link 'Assign yourself to these issues'
+
+ expect(page).to have_content '2 issues have been assigned to you'
+ end
+
+ it 'returns user to the merge request', :js do
+ click_link 'Assign yourself to these issues'
+
+ expect(page).to have_content merge_request.description
+ end
+
+ context 'when related issues are already assigned' do
+ before do
+ [issue1, issue2].each { |issue| issue.update!(assignees: [user]) }
+ end
+
+ it 'does not display if related issues are already assigned' do
+ expect(page).not_to have_content 'Assign yourself'
+ end
+ end
+ end
+
+ context 'logged in as a non-member of the project' do
+ before do
+ sign_in(create(:user))
+ visit project_merge_request_path(project, merge_request)
+ end
+
+ it 'does not not show assignment link' do
+ expect(page).not_to have_content 'Assign yourself'
+ end
+ end
+end
diff --git a/spec/features/merge_requests/award_spec.rb b/spec/features/merge_request/user_awards_emoji_spec.rb
index a24464f2556..15a0878fb16 100644
--- a/spec/features/merge_requests/award_spec.rb
+++ b/spec/features/merge_request/user_awards_emoji_spec.rb
@@ -1,8 +1,8 @@
require 'rails_helper'
-feature 'Merge request awards', :js do
- let(:user) { create(:user) }
+describe 'Merge request > User awards emoji', :js do
let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
let(:merge_request) { create(:merge_request, source_project: project) }
describe 'logged in' do
diff --git a/spec/features/merge_requests/cherry_pick_spec.rb b/spec/features/merge_request/user_cherry_picks_spec.rb
index 205e38337d1..494096b21c0 100644
--- a/spec/features/merge_requests/cherry_pick_spec.rb
+++ b/spec/features/merge_request/user_cherry_picks_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require 'rails_helper'
-describe 'Cherry-pick Merge Requests', :js do
- let(:user) { create(:user) }
+describe 'Merge request > User cherry-picks', :js do
let(:group) { create(:group) }
let(:project) { create(:project, :repository, namespace: group) }
+ let(:user) { project.creator }
let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user) }
before do
- sign_in user
project.add_master(user)
+ sign_in(user)
end
- context "Viewing a merged merge request" do
+ context 'Viewing a merged merge request' do
before do
service = MergeRequests::MergeService.new(project, user)
@@ -21,24 +21,24 @@ describe 'Cherry-pick Merge Requests', :js do
end
# Fast-forward merge, or merged before GitLab 8.5.
- context "Without a merge commit" do
+ context 'Without a merge commit' do
before do
merge_request.merge_commit_sha = nil
merge_request.save
end
- it "doesn't show a Cherry-pick button" do
+ it 'does not show a Cherry-pick button' do
visit project_merge_request_path(project, merge_request)
- expect(page).not_to have_link "Cherry-pick"
+ expect(page).not_to have_link 'Cherry-pick'
end
end
- context "With a merge commit" do
- it "shows a Cherry-pick button" do
+ context 'With a merge commit' do
+ it 'shows a Cherry-pick button' do
visit project_merge_request_path(project, merge_request)
- expect(page).to have_link "Cherry-pick"
+ expect(page).to have_link 'Cherry-pick'
end
end
end
diff --git a/spec/features/merge_requests/image_diff_notes_spec.rb b/spec/features/merge_request/user_creates_image_diff_notes_spec.rb
index d0f8da4e6cd..7c4fd25bb39 100644
--- a/spec/features/merge_requests/image_diff_notes_spec.rb
+++ b/spec/features/merge_request/user_creates_image_diff_notes_spec.rb
@@ -1,14 +1,13 @@
require 'spec_helper'
-feature 'image diff notes', :js do
+feature 'Merge request > User creates image diff notes', :js do
include NoteInteractionHelpers
- let(:user) { create(:user) }
let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
before do
- project.add_master(user)
- sign_in user
+ sign_in(user)
# Stub helper to return any blob file as image from public app folder.
# This is necessary to run this specs since we don't display repo images in capybara.
@@ -25,20 +24,14 @@ feature 'image diff notes', :js do
create_image_diff_note
end
- it 'shows indicator badge on image diff' do
+ it 'shows indicator and avatar badges, and allows collapsing/expanding the discussion notes' do
indicator = find('.js-image-badge')
-
- expect(indicator).to have_content('1')
- end
-
- it 'shows the avatar badge on the new note' do
badge = find('.image-diff-avatar-link .badge')
+ expect(indicator).to have_content('1')
expect(badge).to have_content('1')
- end
- it 'allows collapsing/expanding the discussion notes' do
- find('.js-diff-notes-toggle', :first).click
+ find('.js-diff-notes-toggle').click
expect(page).not_to have_content('image diff test comment')
@@ -86,15 +79,9 @@ feature 'image diff notes', :js do
wait_for_requests
end
- it 'render diff indicators within the image diff frame' do
+ it 'render diff indicators within the image diff frame, diff notes, and avatar badge numbers' do
expect(page).to have_css('.js-image-badge', count: 2)
- end
-
- it 'shows the diff notes' do
expect(page).to have_css('.diff-content .note', count: 2)
- end
-
- it 'shows the diff notes with correct avatar badge numbers' do
expect(page).to have_css('.image-diff-avatar-link', text: 1)
expect(page).to have_css('.image-diff-avatar-link', text: 2)
end
@@ -127,19 +114,13 @@ feature 'image diff notes', :js do
create_image_diff_note
end
- it 'shows indicator badge on image diff' do
+ it 'shows indicator and avatar badges, and allows collapsing/expanding the discussion notes' do
indicator = find('.js-image-badge', match: :first)
-
- expect(indicator).to have_content('1')
- end
-
- it 'shows the avatar badge on the new note' do
badge = find('.image-diff-avatar-link .badge', match: :first)
+ expect(indicator).to have_content('1')
expect(badge).to have_content('1')
- end
- it 'allows expanding/collapsing the discussion notes' do
page.all('.js-diff-notes-toggle')[0].click
page.all('.js-diff-notes-toggle')[1].click
@@ -154,7 +135,7 @@ feature 'image diff notes', :js do
end
end
- describe 'discussion tab polling', :js do
+ describe 'discussion tab polling' do
let(:merge_request) { create(:merge_request_with_diffs, :with_image_diffs, source_project: project, author: user) }
let(:path) { "files/images/ee_repo_logo.png" }
diff --git a/spec/features/merge_request/user_creates_mr_spec.rb b/spec/features/merge_request/user_creates_mr_spec.rb
new file mode 100644
index 00000000000..1ac31de62cb
--- /dev/null
+++ b/spec/features/merge_request/user_creates_mr_spec.rb
@@ -0,0 +1,31 @@
+require 'rails_helper'
+
+describe 'Merge request > User creates MR' do
+ it_behaves_like 'a creatable merge request'
+
+ context 'from a forked project' do
+ include ProjectForksHelper
+
+ let(:canonical_project) { create(:project, :public, :repository) }
+
+ let(:source_project) do
+ fork_project(canonical_project, user,
+ repository: true,
+ namespace: user.namespace)
+ end
+
+ context 'to canonical project' do
+ it_behaves_like 'a creatable merge request'
+ end
+
+ context 'to another forked project' do
+ let(:target_project) do
+ fork_project(canonical_project, user,
+ repository: true,
+ namespace: user.namespace)
+ end
+
+ it_behaves_like 'a creatable merge request'
+ end
+ end
+end
diff --git a/spec/features/merge_requests/merge_commit_message_toggle_spec.rb b/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb
index ddd034e1376..e1e70b6d260 100644
--- a/spec/features/merge_requests/merge_commit_message_toggle_spec.rb
+++ b/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Clicking toggle commit message link', :js do
- let(:user) { create(:user) }
+describe 'Merge request < User customizes merge commit message', :js do
let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
let(:issue_1) { create(:issue, project: project)}
let(:issue_2) { create(:issue, project: project)}
let(:merge_request) do
@@ -33,17 +33,14 @@ feature 'Clicking toggle commit message link', :js do
before do
project.add_master(user)
-
- sign_in user
-
+ sign_in(user)
visit project_merge_request_path(project, merge_request)
+ end
+ it 'toggles commit message between message with description and without description' do
expect(page).not_to have_selector('.js-commit-message')
click_button "Modify commit message"
expect(textbox).to be_visible
- end
-
- it "toggles commit message between message with description and without description " do
expect(textbox.value).to eq(default_message)
click_link "Include description in commit message"
diff --git a/spec/features/merge_request/user_edits_mr_spec.rb b/spec/features/merge_request/user_edits_mr_spec.rb
new file mode 100644
index 00000000000..8c9e782aa76
--- /dev/null
+++ b/spec/features/merge_request/user_edits_mr_spec.rb
@@ -0,0 +1,11 @@
+require 'rails_helper'
+
+describe 'Merge request > User edits MR' do
+ it_behaves_like 'an editable merge request'
+
+ context 'for a forked project' do
+ it_behaves_like 'an editable merge request' do
+ let(:source_project) { create(:project, :repository, forked_from_project: target_project) }
+ end
+ end
+end
diff --git a/spec/features/merge_requests/discussion_lock_spec.rb b/spec/features/merge_request/user_locks_discussion_spec.rb
index 7bbd3b1e69e..a68df872334 100644
--- a/spec/features/merge_requests/discussion_lock_spec.rb
+++ b/spec/features/merge_request/user_locks_discussion_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require 'rails_helper'
-describe 'Discussion Lock', :js do
+describe 'Merge request > User locks discussion', :js do
let(:user) { create(:user) }
- let(:merge_request) { create(:merge_request, source_project: project, author: user) }
let(:project) { create(:project, :public, :repository) }
+ let(:merge_request) { create(:merge_request, source_project: project) }
before do
sign_in(user)
diff --git a/spec/features/merge_requests/merge_immediately_with_pipeline_spec.rb b/spec/features/merge_request/user_merges_immediately_spec.rb
index e1317b33ad1..b16fc9bfc89 100644
--- a/spec/features/merge_requests/merge_immediately_with_pipeline_spec.rb
+++ b/spec/features/merge_request/user_merges_immediately_spec.rb
@@ -1,9 +1,8 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Merge immediately', :js do
- let(:user) { create(:user) }
+describe 'Merge requests > User merges immediately', :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,
@@ -11,25 +10,18 @@ feature 'Merge immediately', :js do
head_pipeline: pipeline,
source_branch: pipeline.ref)
end
-
let(:pipeline) do
create(:ci_pipeline, project: project,
ref: 'master',
sha: project.repository.commit('master').id)
end
- 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
-
before do
- sign_in user
- visit project_merge_request_path(merge_request.project, merge_request)
+ create(:ci_build, pipeline: pipeline)
+ project.add_master(user)
+ sign_in(user)
+ visit project_merge_request_path(project, merge_request)
end
it 'enables merge immediately' do
diff --git a/spec/features/merge_requests/only_allow_merge_if_build_succeeds_spec.rb b/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb
index 7d9282b932b..a045791f6b4 100644
--- a/spec/features/merge_requests/only_allow_merge_if_build_succeeds_spec.rb
+++ b/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb
@@ -1,18 +1,17 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Only allow merge requests to be merged if the pipeline succeeds', :js do
+describe 'Merge request > User merges only if pipeline succeeds', :js do
let(:merge_request) { create(:merge_request_with_diffs) }
let(:project) { merge_request.target_project }
before do
- sign_in merge_request.author
-
project.add_master(merge_request.author)
+ sign_in(merge_request.author)
end
- context 'project does not have CI enabled', :js do
+ context 'project does not have CI enabled' do
it 'allows MR to be merged' do
- visit_merge_request(merge_request)
+ visit project_merge_request_path(project, merge_request)
wait_for_requests
@@ -20,8 +19,8 @@ feature 'Only allow merge requests to be merged if the pipeline succeeds', :js d
end
end
- context 'when project has CI enabled', :js do
- given!(:pipeline) do
+ context 'when project has CI enabled' do
+ let!(:pipeline) do
create(:ci_empty_pipeline,
project: project,
sha: merge_request.diff_head_sha,
@@ -35,10 +34,10 @@ feature 'Only allow merge requests to be merged if the pipeline succeeds', :js d
end
context 'when CI is running' do
- given(:status) { :running }
+ let(:status) { :running }
it 'does not allow to merge immediately' do
- visit_merge_request(merge_request)
+ visit project_merge_request_path(project, merge_request)
wait_for_requests
@@ -48,10 +47,10 @@ feature 'Only allow merge requests to be merged if the pipeline succeeds', :js d
end
context 'when CI failed' do
- given(:status) { :failed }
+ let(:status) { :failed }
it 'does not allow MR to be merged' do
- visit_merge_request(merge_request)
+ visit project_merge_request_path(project, merge_request)
wait_for_requests
@@ -61,10 +60,10 @@ feature 'Only allow merge requests to be merged if the pipeline succeeds', :js d
end
context 'when CI canceled' do
- given(:status) { :canceled }
+ let(:status) { :canceled }
it 'does not allow MR to be merged' do
- visit_merge_request(merge_request)
+ visit project_merge_request_path(project, merge_request)
wait_for_requests
@@ -74,10 +73,10 @@ feature 'Only allow merge requests to be merged if the pipeline succeeds', :js d
end
context 'when CI succeeded' do
- given(:status) { :success }
+ let(:status) { :success }
it 'allows MR to be merged' do
- visit_merge_request(merge_request)
+ visit project_merge_request_path(project, merge_request)
wait_for_requests
@@ -86,10 +85,10 @@ feature 'Only allow merge requests to be merged if the pipeline succeeds', :js d
end
context 'when CI skipped' do
- given(:status) { :skipped }
+ let(:status) { :skipped }
it 'allows MR to be merged' do
- visit_merge_request(merge_request)
+ visit project_merge_request_path(project, merge_request)
wait_for_requests
@@ -104,10 +103,10 @@ feature 'Only allow merge requests to be merged if the pipeline succeeds', :js d
end
context 'when CI is running' do
- given(:status) { :running }
+ let(:status) { :running }
it 'allows MR to be merged immediately' do
- visit_merge_request(merge_request)
+ visit project_merge_request_path(project, merge_request)
wait_for_requests
@@ -119,10 +118,10 @@ feature 'Only allow merge requests to be merged if the pipeline succeeds', :js d
end
context 'when CI failed' do
- given(:status) { :failed }
+ let(:status) { :failed }
it 'allows MR to be merged' do
- visit_merge_request(merge_request)
+ visit project_merge_request_path(project, merge_request)
wait_for_requests
@@ -131,10 +130,10 @@ feature 'Only allow merge requests to be merged if the pipeline succeeds', :js d
end
context 'when CI succeeded' do
- given(:status) { :success }
+ let(:status) { :success }
it 'allows MR to be merged' do
- visit_merge_request(merge_request)
+ visit project_merge_request_path(project, merge_request)
wait_for_requests
@@ -143,8 +142,4 @@ feature 'Only allow merge requests to be merged if the pipeline succeeds', :js d
end
end
end
-
- def visit_merge_request(merge_request)
- visit project_merge_request_path(merge_request.project, merge_request)
- end
end
diff --git a/spec/features/merge_requests/merge_when_pipeline_succeeds_spec.rb b/spec/features/merge_request/user_merges_when_pipeline_succeeds_spec.rb
index ac46cc1f0e4..890774922aa 100644
--- a/spec/features/merge_requests/merge_when_pipeline_succeeds_spec.rb
+++ b/spec/features/merge_request/user_merges_when_pipeline_succeeds_spec.rb
@@ -1,16 +1,14 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Merge When Pipeline Succeeds', :js do
- let(:user) { create(:user) }
+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,
@@ -23,17 +21,10 @@ feature 'Merge When Pipeline Succeeds', :js do
end
context 'when there is active pipeline for merge request' do
- background do
- create(:ci_build, pipeline: pipeline)
- end
-
before do
- sign_in 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"
+ create(:ci_build, pipeline: pipeline)
+ sign_in(user)
+ visit project_merge_request_path(project, merge_request)
end
describe 'enabling Merge when pipeline succeeds' do
@@ -44,7 +35,7 @@ feature 'Merge When Pipeline Succeeds', :js do
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"
expect(page).to have_selector ".js-cancel-auto-merge"
- visit_merge_request(merge_request) # Needed to refresh the page
+ 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
end
@@ -115,14 +106,13 @@ feature 'Merge When Pipeline Succeeds', :js do
title: 'MepMep',
merge_when_pipeline_succeeds: true)
end
-
let!(:build) do
create(:ci_build, pipeline: pipeline)
end
before do
sign_in user
- visit_merge_request(merge_request)
+ visit project_merge_request_path(project, merge_request)
end
it 'allows to cancel the automatic merge' do
@@ -130,31 +120,67 @@ feature 'Merge When Pipeline Succeeds', :js do
expect(page).to have_button "Merge when pipeline succeeds"
- visit_merge_request(merge_request) # refresh the page
+ refresh
+
expect(page).to have_content "canceled the automatic merge"
end
context 'when pipeline succeeds' do
- background { build.success }
+ before do
+ build.success
+ refresh
+ end
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
+
+ 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-widget-body') do
+ expect(page).to have_content('Something went wrong')
+ 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-widget-body') do
+ expect(page).to have_content('Something went wrong')
+ end
+ end
+ end
end
context 'when pipeline is not active' do
- it "does not allow to enable merge when pipeline succeeds" do
- visit_merge_request(merge_request)
+ 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'
end
end
-
- def visit_merge_request(merge_request)
- visit project_merge_request_path(merge_request.project, merge_request)
- end
end
diff --git a/spec/features/merge_requests/user_posts_diff_notes_spec.rb b/spec/features/merge_request/user_posts_diff_notes_spec.rb
index d44eb23d7f4..2b4623d6dc9 100644
--- a/spec/features/merge_requests/user_posts_diff_notes_spec.rb
+++ b/spec/features/merge_request/user_posts_diff_notes_spec.rb
@@ -1,11 +1,15 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Merge requests > User posts diff notes', :js do
+describe 'Merge request > User posts diff notes', :js do
include MergeRequestDiffHelpers
- let(:user) { create(:user) }
let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.source_project }
+ let(:user) { project.creator }
+ let(:comment_button_class) { '.add-diff-note' }
+ let(:notes_holder_input_class) { 'js-temp-notes-holder' }
+ let(:notes_holder_input_xpath) { './following-sibling::*[contains(concat(" ", @class, " "), " notes_holder ")]' }
+ let(:test_note_comment) { 'this is a test note!' }
before do
set_cookie('sidebar_collapsed', 'true')
@@ -14,11 +18,6 @@ feature 'Merge requests > User posts diff notes', :js do
sign_in(user)
end
- let(:comment_button_class) { '.add-diff-note' }
- let(:notes_holder_input_class) { 'js-temp-notes-holder' }
- let(:notes_holder_input_xpath) { './following-sibling::*[contains(concat(" ", @class, " "), " notes_holder ")]' }
- let(:test_note_comment) { 'this is a test note!' }
-
context 'when hovering over a parallel view diff file' do
before do
visit diffs_project_merge_request_path(project, merge_request, view: 'parallel')
diff --git a/spec/features/merge_requests/user_posts_notes_spec.rb b/spec/features/merge_request/user_posts_notes_spec.rb
index e17e9c2ccf5..50d06565fc0 100644
--- a/spec/features/merge_requests/user_posts_notes_spec.rb
+++ b/spec/features/merge_request/user_posts_notes_spec.rb
@@ -1,9 +1,10 @@
-require 'spec_helper'
+require 'rails_helper'
-describe 'Merge requests > User posts notes', :js do
+describe 'Merge request > User posts notes', :js do
include NoteInteractionHelpers
let(:project) { create(:project, :repository) }
+ let(:user) { project.creator }
let(:merge_request) do
create(:merge_request, source_project: project, target_project: project)
end
@@ -13,7 +14,8 @@ describe 'Merge requests > User posts notes', :js do
end
before do
- sign_in(create(:admin))
+ project.add_master(user)
+ sign_in(user)
visit project_merge_request_path(project, merge_request)
end
diff --git a/spec/features/merge_requests/conflicts_spec.rb b/spec/features/merge_request/user_resolves_conflicts_spec.rb
index 05d99a2dff2..61861d33952 100644
--- a/spec/features/merge_requests/conflicts_spec.rb
+++ b/spec/features/merge_request/user_resolves_conflicts_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Merge request conflict resolution', :js do
- let(:user) { create(:user) }
+describe 'Merge request > User resolves conflicts', :js do
let(:project) { create(:project, :repository) }
+ let(:user) { project.creator }
before do
# In order to have the diffs collapsed, we need to disable the increase feature
@@ -177,7 +177,6 @@ feature 'Merge request conflict resolution', :js do
before do
project.add_developer(user)
sign_in(user)
-
visit project_merge_request_path(project, merge_request)
end
diff --git a/spec/features/merge_requests/diff_notes_resolve_spec.rb b/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb
index 9d4194d8ca0..590210d44ef 100644
--- a/spec/features/merge_requests/diff_notes_resolve_spec.rb
+++ b/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb
@@ -1,10 +1,11 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Diff notes resolve', :js do
- let(:user) { create(:user) }
+describe 'Merge request > User resolves diff notes and discussions', :js do
let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
+ let(:guest) { create(:user) }
let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user, title: "Bug NS-04") }
- let!(:note) { create(:diff_note_on_merge_request, project: project, noteable: merge_request) }
+ let!(:note) { create(:diff_note_on_merge_request, project: project, noteable: merge_request) }
let(:path) { "files/ruby/popen.rb" }
let(:position) do
Gitlab::Diff::Position.new(
@@ -19,7 +20,7 @@ feature 'Diff notes resolve', :js do
context 'no discussions' do
before do
project.add_master(user)
- sign_in user
+ sign_in(user)
note.destroy
visit_merge_request
end
@@ -33,7 +34,7 @@ feature 'Diff notes resolve', :js do
context 'as authorized user' do
before do
project.add_master(user)
- sign_in user
+ sign_in(user)
visit_merge_request
end
@@ -67,6 +68,8 @@ feature 'Diff notes resolve', :js do
click_button 'Resolve discussion'
end
+ expect(page).to have_selector('.discussion-body', visible: false)
+
page.within '.diff-content .note' do
expect(page).to have_selector('.line-resolve-btn.is-active')
end
@@ -318,9 +321,7 @@ feature 'Diff notes resolve', :js do
end
it 'shows jump to next discussion button' do
- page.all('.discussion-reply-holder').each do |holder|
- expect(holder).to have_selector('.discussion-next-btn')
- end
+ expect(page.all('.discussion-reply-holder')).to all(have_selector('.discussion-next-btn'))
end
it 'displays next discussion even if hidden' do
@@ -426,11 +427,9 @@ feature 'Diff notes resolve', :js do
end
context 'as a guest' do
- let(:guest) { create(:user) }
-
before do
project.add_guest(guest)
- sign_in guest
+ sign_in(guest)
end
context 'someone elses merge request' do
@@ -456,10 +455,10 @@ feature 'Diff notes resolve', :js do
end
context 'guest users merge request' do
+ let(:user) { guest }
+
before do
- mr = create(:merge_request_with_diffs, source_project: project, source_branch: 'markdown', author: guest, title: "Bug")
- create(:diff_note_on_merge_request, project: project, noteable: mr)
- visit_merge_request(mr)
+ visit_merge_request
end
it 'allows user to mark a note as resolved' do
@@ -521,7 +520,7 @@ feature 'Diff notes resolve', :js do
end
def visit_merge_request(mr = nil)
- mr = mr || merge_request
+ mr ||= merge_request
visit project_merge_request_path(mr.project, mr)
end
end
diff --git a/spec/features/merge_requests/resolve_outdated_diff_discussions.rb b/spec/features/merge_request/user_resolves_outdated_diff_discussions_spec.rb
index 25abbb469ab..9ba9e8b9585 100644
--- a/spec/features/merge_requests/resolve_outdated_diff_discussions.rb
+++ b/spec/features/merge_request/user_resolves_outdated_diff_discussions_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-feature 'Resolve outdated diff discussions', :js do
+feature 'Merge request > User resolves outdated diff discussions', :js do
let(:project) { create(:project, :repository, :public) }
let(:merge_request) do
diff --git a/spec/features/merge_request/user_scrolls_to_note_on_load_spec.rb b/spec/features/merge_request/user_scrolls_to_note_on_load_spec.rb
new file mode 100644
index 00000000000..8a834adbf17
--- /dev/null
+++ b/spec/features/merge_request/user_scrolls_to_note_on_load_spec.rb
@@ -0,0 +1,26 @@
+require 'rails_helper'
+
+describe 'Merge request > User scrolls to note on load', :js do
+ let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
+ let(:merge_request) { create(:merge_request, source_project: project, author: user) }
+ let(:note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project) }
+ let(:fragment_id) { "#note_#{note.id}" }
+
+ before do
+ sign_in(user)
+ page.current_window.resize_to(1000, 300)
+ visit "#{project_merge_request_path(project, merge_request)}#{fragment_id}"
+ end
+
+ it 'scrolls down to fragment' do
+ page_height = page.current_window.size[1]
+ page_scroll_y = page.evaluate_script("window.scrollY")
+ fragment_position_top = page.evaluate_script("Math.round($('#{fragment_id}').offset().top)")
+
+ expect(find('.js-toggle-content').visible?).to eq true
+ expect(find(fragment_id).visible?).to eq true
+ expect(fragment_position_top).to be >= page_scroll_y
+ expect(fragment_position_top).to be < (page_scroll_y + page_height)
+ end
+end
diff --git a/spec/features/merge_requests/diff_notes_avatars_spec.rb b/spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb
index ef8f314cc03..9c0a04405a6 100644
--- a/spec/features/merge_requests/diff_notes_avatars_spec.rb
+++ b/spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Diff note avatars', :js do
+describe 'Merge request > User sees avatars on diff notes', :js do
include NoteInteractionHelpers
- let(:user) { create(:user) }
let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user, title: "Bug NS-04") }
let(:path) { "files/ruby/popen.rb" }
let(:position) do
@@ -151,7 +151,6 @@ feature 'Diff note avatars', :js do
page.within '.js-discussion-note-form' do
find('.js-note-text').native.send_keys('Test')
-
find('.js-comment-button').click
wait_for_requests
@@ -169,7 +168,6 @@ feature 'Diff note avatars', :js do
context 'multiple comments' do
before do
create_list(:diff_note_on_merge_request, 3, project: project, noteable: merge_request, in_reply_to: note)
-
visit diffs_project_merge_request_path(project, merge_request, view: view)
wait_for_requests
diff --git a/spec/features/merge_requests/closes_issues_spec.rb b/spec/features/merge_request/user_sees_closing_issues_message_spec.rb
index 55de9a01ed5..726f35557a7 100644
--- a/spec/features/merge_requests/closes_issues_spec.rb
+++ b/spec/features/merge_request/user_sees_closing_issues_message_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Merge Request closing issues message', :js do
- let(:user) { create(:user) }
+describe 'Merge request > User sees closing issues message', :js do
let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
let(:issue_1) { create(:issue, project: project)}
let(:issue_2) { create(:issue, project: project)}
let(:merge_request) do
@@ -19,9 +19,7 @@ feature 'Merge Request closing issues message', :js do
before do
project.add_master(user)
-
- sign_in user
-
+ sign_in(user)
visit project_merge_request_path(project, merge_request)
wait_for_requests
end
diff --git a/spec/features/merge_request/user_sees_deleted_target_branch_spec.rb b/spec/features/merge_request/user_sees_deleted_target_branch_spec.rb
new file mode 100644
index 00000000000..01115318370
--- /dev/null
+++ b/spec/features/merge_request/user_sees_deleted_target_branch_spec.rb
@@ -0,0 +1,22 @@
+require 'rails_helper'
+
+describe 'Merge request > User sees deleted target branch', :js do
+ let(:merge_request) { create(:merge_request) }
+ let(:project) { merge_request.project }
+ let(:user) { project.creator }
+
+ before do
+ project.add_master(user)
+ DeleteBranchService.new(project, user).execute('feature')
+ sign_in(user)
+ visit project_merge_request_path(project, merge_request)
+ end
+
+ it 'shows a message about missing target branch' do
+ expect(page).to have_content('Target branch does not exist')
+ end
+
+ it 'does not show link to target branch' do
+ expect(page).not_to have_selector('.mr-widget-body .js-branch-text a')
+ end
+end
diff --git a/spec/features/merge_request/user_sees_deployment_widget_spec.rb b/spec/features/merge_request/user_sees_deployment_widget_spec.rb
new file mode 100644
index 00000000000..3abe363d523
--- /dev/null
+++ b/spec/features/merge_request/user_sees_deployment_widget_spec.rb
@@ -0,0 +1,56 @@
+require 'rails_helper'
+
+describe 'Merge request > User sees deployment widget', :js do
+ describe 'when deployed to an environment' do
+ let(:user) { create(:user) }
+ let(:project) { merge_request.target_project }
+ let(:merge_request) { create(:merge_request, :merged) }
+ let(:environment) { create(:environment, project: project) }
+ let(:role) { :developer }
+ let(:sha) { project.commit('master').id }
+ let!(:deployment) { create(:deployment, environment: environment, sha: sha) }
+ let!(:manual) { }
+
+ before do
+ project.add_user(user, role)
+ sign_in(user)
+ visit project_merge_request_path(project, merge_request)
+ wait_for_requests
+ end
+
+ it 'displays that the environment is deployed' do
+ wait_for_requests
+
+ expect(page).to have_content("Deployed to #{environment.name}")
+ expect(find('.js-deploy-time')['data-title']).to eq(deployment.created_at.to_time.in_time_zone.to_s(:medium))
+ end
+
+ context 'with stop action' do
+ let(:pipeline) { create(:ci_pipeline, project: project) }
+ let(:build) { create(:ci_build, pipeline: pipeline) }
+ let(:manual) { create(:ci_build, :manual, pipeline: pipeline, name: 'close_app') }
+ let(:deployment) do
+ create(:deployment, environment: environment, ref: merge_request.target_branch,
+ sha: sha, deployable: build, on_stop: 'close_app')
+ end
+
+ before do
+ wait_for_requests
+ end
+
+ it 'does start build when stop button clicked' do
+ accept_confirm { click_button('Stop environment') }
+
+ expect(page).to have_content('close_app')
+ end
+
+ context 'for reporter' do
+ let(:role) { :reporter }
+
+ it 'does not show stop button' do
+ expect(page).not_to have_button('Stop environment')
+ end
+ end
+ end
+ end
+end
diff --git a/spec/features/merge_requests/diffs_spec.rb b/spec/features/merge_request/user_sees_diff_spec.rb
index 1bf77296ae6..a9063f2bcb3 100644
--- a/spec/features/merge_requests/diffs_spec.rb
+++ b/spec/features/merge_request/user_sees_diff_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Diffs URL', :js do
+describe 'Merge request > User sees diff', :js do
include ProjectForksHelper
let(:project) { create(:project, :public, :repository) }
diff --git a/spec/features/merge_requests/discussion_spec.rb b/spec/features/merge_request/user_sees_discussions_spec.rb
index 05789bbd31d..d6e8c8e86ba 100644
--- a/spec/features/merge_requests/discussion_spec.rb
+++ b/spec/features/merge_request/user_sees_discussions_spec.rb
@@ -1,19 +1,20 @@
-require 'spec_helper'
+require 'rails_helper'
+
+describe 'Merge request > User sees discussions' do
+ let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
+ let(:merge_request) { create(:merge_request, source_project: project) }
-feature 'Merge Request Discussions' do
before do
- sign_in(create(:admin))
+ project.add_master(user)
+ sign_in(user)
end
describe "Diff discussions" do
- let(:merge_request) { create(:merge_request, importing: true) }
- let(:project) { merge_request.source_project }
let!(:old_merge_request_diff) { merge_request.merge_request_diffs.create(diff_refs: outdated_diff_refs) }
let!(:new_merge_request_diff) { merge_request.merge_request_diffs.create }
-
let!(:outdated_discussion) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: outdated_position).to_discussion }
let!(:active_discussion) { create(:diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion }
-
let(:outdated_position) do
Gitlab::Diff::Position.new(
old_path: "files/ruby/popen.rb",
@@ -23,7 +24,6 @@ feature 'Merge Request Discussions' do
diff_refs: outdated_diff_refs
)
end
-
let(:outdated_diff_refs) { project.commit("874797c3a73b60d2187ed6e2fcabd289ff75171e").diff_refs }
before do
@@ -50,9 +50,6 @@ feature 'Merge Request Discussions' do
end
describe 'Commit comments displayed in MR context', :js do
- let(:merge_request) { create(:merge_request) }
- let(:project) { merge_request.project }
-
shared_examples 'a functional discussion' do
let(:discussion_id) { note.discussion_id(merge_request) }
diff --git a/spec/features/merge_request/user_sees_empty_state_spec.rb b/spec/features/merge_request/user_sees_empty_state_spec.rb
new file mode 100644
index 00000000000..a939c7e9001
--- /dev/null
+++ b/spec/features/merge_request/user_sees_empty_state_spec.rb
@@ -0,0 +1,30 @@
+require 'rails_helper'
+
+describe 'Merge request > User sees empty state' do
+ let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
+
+ before do
+ project.add_master(user)
+ sign_in(user)
+ end
+
+ it 'shows an empty state and a "New merge request" button' do
+ visit project_merge_requests_path(project)
+
+ expect(page).to have_selector('.empty-state')
+ expect(page).to have_link 'New merge request', href: project_new_merge_request_path(project)
+ end
+
+ context 'if there are merge requests' do
+ before do
+ create(:merge_request, source_project: project)
+
+ visit project_merge_requests_path(project)
+ end
+
+ it 'does not show an empty state' do
+ expect(page).not_to have_selector('.empty-state')
+ end
+ end
+end
diff --git a/spec/features/merge_requests/check_if_mergeable_with_unresolved_discussions_spec.rb b/spec/features/merge_request/user_sees_merge_button_depending_on_unresolved_discussions_spec.rb
index 892c32c8806..85df43df38e 100644
--- a/spec/features/merge_requests/check_if_mergeable_with_unresolved_discussions_spec.rb
+++ b/spec/features/merge_request/user_sees_merge_button_depending_on_unresolved_discussions_spec.rb
@@ -1,24 +1,23 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Check if mergeable with unresolved discussions', :js do
- let(:user) { create(:user) }
+describe 'Merge request > User sees merge button depending on unresolved discussions', :js do
let(:project) { create(:project, :repository) }
+ let(:user) { project.creator }
let!(:merge_request) { create(:merge_request_with_diff_notes, source_project: project, author: user) }
before do
- sign_in user
project.add_master(user)
+ sign_in(user)
end
context 'when project.only_allow_merge_if_all_discussions_are_resolved == true' do
before do
project.update_column(:only_allow_merge_if_all_discussions_are_resolved, true)
+ visit project_merge_request_path(project, merge_request)
end
context 'with unresolved discussions' do
it 'does not allow to merge' do
- visit_merge_request(merge_request)
-
expect(page).not_to have_button 'Merge'
expect(page).to have_content('There are unresolved discussions.')
end
@@ -27,11 +26,10 @@ feature 'Check if mergeable with unresolved discussions', :js do
context 'with all discussions resolved' do
before do
merge_request.discussions.each { |d| d.resolve!(user) }
+ visit project_merge_request_path(project, merge_request)
end
it 'allows MR to be merged' do
- visit_merge_request(merge_request)
-
expect(page).to have_button 'Merge'
end
end
@@ -40,12 +38,11 @@ feature 'Check if mergeable with unresolved discussions', :js do
context 'when project.only_allow_merge_if_all_discussions_are_resolved == false' do
before do
project.update_column(:only_allow_merge_if_all_discussions_are_resolved, false)
+ visit project_merge_request_path(project, merge_request)
end
context 'with unresolved discussions' do
it 'does not allow to merge' do
- visit_merge_request(merge_request)
-
expect(page).to have_button 'Merge'
end
end
@@ -53,17 +50,12 @@ feature 'Check if mergeable with unresolved discussions', :js do
context 'with all discussions resolved' do
before do
merge_request.discussions.each { |d| d.resolve!(user) }
+ visit project_merge_request_path(project, merge_request)
end
it 'allows MR to be merged' do
- visit_merge_request(merge_request)
-
expect(page).to have_button 'Merge'
end
end
end
-
- def visit_merge_request(merge_request)
- visit project_merge_request_path(merge_request.project, merge_request)
- end
end
diff --git a/spec/features/merge_requests/widget_spec.rb b/spec/features/merge_request/user_sees_merge_widget_spec.rb
index 8970586a160..56224e505d9 100644
--- a/spec/features/merge_requests/widget_spec.rb
+++ b/spec/features/merge_request/user_sees_merge_widget_spec.rb
@@ -1,9 +1,9 @@
require 'rails_helper'
-describe 'Merge request', :js do
- let(:user) { create(:user) }
+describe 'Merge request > User sees merge widget', :js do
let(:project) { create(:project, :repository) }
let(:project_only_mwps) { create(:project, :repository, only_allow_merge_if_pipeline_succeeds: true) }
+ let(:user) { project.creator }
let(:merge_request) { create(:merge_request, source_project: project) }
let(:merge_request_in_only_mwps_project) { create(:merge_request, source_project: project_only_mwps) }
diff --git a/spec/features/merge_requests/mini_pipeline_graph_spec.rb b/spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb
index a7e7c0eeff6..a43ba05c64c 100644
--- a/spec/features/merge_requests/mini_pipeline_graph_spec.rb
+++ b/spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb
@@ -1,16 +1,14 @@
require 'rails_helper'
-feature 'Mini Pipeline Graph', :js do
- let(:user) { create(:user) }
+describe 'Merge request < User sees mini pipeline graph', :js do
let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
let(:merge_request) { create(:merge_request, source_project: project, head_pipeline: pipeline) }
-
let(:pipeline) { create(:ci_empty_pipeline, project: project, ref: 'master', status: 'running', sha: project.commit.id) }
let(:build) { create(:ci_build, pipeline: pipeline, stage: 'test', commands: 'test') }
before do
build.run
-
sign_in(user)
visit_merge_request
end
@@ -19,13 +17,13 @@ feature 'Mini Pipeline Graph', :js do
visit project_merge_request_path(project, merge_request, format: format, serializer: serializer)
end
- it 'should display a mini pipeline graph' do
+ it 'displays a mini pipeline graph' do
expect(page).to have_selector('.mr-widget-pipeline-graph')
end
context 'as json' do
- let(:artifacts_file1) { fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') }
- let(:artifacts_file2) { fixture_file_upload(Rails.root + 'spec/fixtures/dk.png', 'image/png') }
+ let(:artifacts_file1) { fixture_file_upload(Rails.root.join('spec/fixtures/banana_sample.gif'), 'image/gif') }
+ let(:artifacts_file2) { fixture_file_upload(Rails.root.join('spec/fixtures/dk.png'), 'image/png') }
before do
create(:ci_build, pipeline: pipeline, legacy_artifacts_file: artifacts_file1)
@@ -51,7 +49,7 @@ feature 'Mini Pipeline Graph', :js do
first('.mini-pipeline-graph-dropdown-toggle')
end
- it 'should expand when hovered' do
+ it 'expands when hovered' do
find('.mini-pipeline-graph-dropdown-toggle')
before_width = evaluate_script("$('.mini-pipeline-graph-dropdown-toggle:visible').outerWidth();")
@@ -63,13 +61,13 @@ feature 'Mini Pipeline Graph', :js do
expect(before_width).to be < after_width
end
- it 'should show dropdown caret when hovered' do
+ it 'shows dropdown caret when hovered' do
toggle.hover
expect(toggle).to have_selector('.fa-caret-down')
end
- it 'should show tooltip when hovered' do
+ it 'shows tooltip when hovered' do
toggle.hover
expect(page).to have_selector('.tooltip')
@@ -87,17 +85,17 @@ feature 'Mini Pipeline Graph', :js do
wait_for_requests
end
- it 'should open when toggle is clicked' do
+ it 'pens when toggle is clicked' do
expect(toggle.find(:xpath, '..')).to have_selector('.mini-pipeline-graph-dropdown-menu')
end
- it 'should close when toggle is clicked again' do
+ it 'closes when toggle is clicked again' do
toggle.click
expect(toggle.find(:xpath, '..')).not_to have_selector('.mini-pipeline-graph-dropdown-menu')
end
- it 'should close when clicking somewhere else' do
+ it 'closes when clicking somewhere else' do
find('body').click
expect(toggle.find(:xpath, '..')).not_to have_selector('.mini-pipeline-graph-dropdown-menu')
@@ -109,14 +107,14 @@ feature 'Mini Pipeline Graph', :js do
first('.mini-pipeline-graph-dropdown-item')
end
- it 'should visit the build page when clicked' do
+ it 'visits the build page when clicked' do
build_item.click
find('.build-page')
expect(current_path).to eql(project_job_path(project, build))
end
- it 'should show tooltip when hovered' do
+ it 'shows tooltip when hovered' do
build_item.hover
expect(page).to have_selector('.tooltip')
diff --git a/spec/features/merge_request/user_sees_mr_from_deleted_forked_project_spec.rb b/spec/features/merge_request/user_sees_mr_from_deleted_forked_project_spec.rb
new file mode 100644
index 00000000000..029b66b5e8e
--- /dev/null
+++ b/spec/features/merge_request/user_sees_mr_from_deleted_forked_project_spec.rb
@@ -0,0 +1,24 @@
+require 'rails_helper'
+
+describe 'Merge request > User sees MR from deleted forked project', :js do
+ let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
+ let(:fork_project) { create(:project, :public, :repository, forked_from_project: project) }
+ let!(:merge_request) do
+ create(:merge_request_with_diffs, source_project: fork_project,
+ target_project: project,
+ description: 'Test merge request')
+ end
+
+ before do
+ MergeRequests::MergeService.new(project, user).execute(merge_request)
+ fork_project.destroy!
+ sign_in(user)
+ visit project_merge_request_path(project, merge_request)
+ end
+
+ it 'user can access merge request' do
+ expect(page).to have_content 'Test merge request'
+ expect(page).to have_content "(removed):#{merge_request.source_branch}"
+ end
+end
diff --git a/spec/features/merge_requests/deleted_source_branch_spec.rb b/spec/features/merge_request/user_sees_mr_with_deleted_source_branch_spec.rb
index 56aa0b2ede2..c1608be402a 100644
--- a/spec/features/merge_requests/deleted_source_branch_spec.rb
+++ b/spec/features/merge_request/user_sees_mr_with_deleted_source_branch_spec.rb
@@ -1,23 +1,21 @@
-require 'spec_helper'
+require 'rails_helper'
# This test serves as a regression test for a bug that caused an error
# message to be shown by JavaScript when the source branch was deleted.
-# Please do not remove "js: true".
-describe 'Deleted source branch', :js do
- let(:user) { create(:user) }
- let(:merge_request) { create(:merge_request) }
+# Please do not remove ":js".
+describe 'Merge request > User sees MR with deleted source branch', :js do
+ let(:project) { create(:project, :public, :repository) }
+ let(:merge_request) { create(:merge_request, source_project: project) }
+ let(:user) { project.creator }
before do
- sign_in user
- merge_request.project.add_master(user)
merge_request.update!(source_branch: 'this-branch-does-not-exist')
- visit project_merge_request_path(merge_request.project, merge_request)
+ sign_in(user)
+ visit project_merge_request_path(project, merge_request)
end
it 'shows a message about missing source branch' do
- expect(page).to have_content(
- 'Source branch does not exist.'
- )
+ expect(page).to have_content('Source branch does not exist.')
end
it 'still contains Discussion, Commits and Changes tabs' do
diff --git a/spec/features/merge_request/user_sees_notes_from_forked_project_spec.rb b/spec/features/merge_request/user_sees_notes_from_forked_project_spec.rb
new file mode 100644
index 00000000000..b4cda269852
--- /dev/null
+++ b/spec/features/merge_request/user_sees_notes_from_forked_project_spec.rb
@@ -0,0 +1,35 @@
+require 'rails_helper'
+
+describe 'Merge request > User sees notes from forked project', :js do
+ let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
+ let(:fork_project) { create(:project, :public, :repository, forked_from_project: project) }
+ let!(:merge_request) do
+ create(:merge_request_with_diffs, source_project: fork_project,
+ target_project: project,
+ description: 'Test merge request')
+ end
+
+ before do
+ create(:note_on_commit, note: 'A commit comment',
+ project: fork_project,
+ commit_id: merge_request.commit_shas.first)
+ sign_in(user)
+ end
+
+ it 'user can reply to the comment' do
+ visit project_merge_request_path(project, merge_request)
+
+ expect(page).to have_content('A commit comment')
+
+ page.within('.discussion-notes') do
+ find('.btn-text-field').click
+ find('#note_note').send_keys('A reply comment')
+ find('.comment-btn').click
+ end
+
+ wait_for_requests
+
+ expect(page).to have_content('A reply comment')
+ end
+end
diff --git a/spec/features/merge_request/user_sees_pipelines_from_forked_project_spec.rb b/spec/features/merge_request/user_sees_pipelines_from_forked_project_spec.rb
new file mode 100644
index 00000000000..d30dcefc6aa
--- /dev/null
+++ b/spec/features/merge_request/user_sees_pipelines_from_forked_project_spec.rb
@@ -0,0 +1,34 @@
+require 'rails_helper'
+
+describe 'Merge request > User sees pipelines from forked project', :js do
+ let(:target_project) { create(:project, :public, :repository) }
+ let(:user) { target_project.creator }
+ let(:fork_project) { create(:project, :repository, forked_from_project: target_project) }
+ let!(:merge_request) do
+ create(:merge_request_with_diffs, source_project: fork_project,
+ target_project: target_project,
+ description: 'Test merge request')
+ end
+ let(:pipeline) do
+ create(:ci_pipeline,
+ project: fork_project,
+ sha: merge_request.diff_head_sha,
+ ref: merge_request.source_branch)
+ end
+
+ before do
+ create(:ci_build, pipeline: pipeline, name: 'rspec')
+ create(:ci_build, pipeline: pipeline, name: 'spinach')
+
+ sign_in(user)
+ visit project_merge_request_path(target_project, merge_request)
+ end
+
+ it 'user visits a pipelines page' do
+ page.within('.merge-request-tabs') { click_link 'Pipelines' }
+
+ page.within('.ci-table') do
+ expect(page).to have_content(pipeline.id)
+ end
+ end
+end
diff --git a/spec/features/merge_requests/pipelines_spec.rb b/spec/features/merge_request/user_sees_pipelines_spec.rb
index 04e3f4bdcf1..a42c016392b 100644
--- a/spec/features/merge_requests/pipelines_spec.rb
+++ b/spec/features/merge_request/user_sees_pipelines_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Pipelines for Merge Requests', :js do
+describe 'Merge request > User sees pipelines', :js do
describe 'pipeline tab' do
- given(:user) { create(:user) }
- given(:merge_request) { create(:merge_request) }
- given(:project) { merge_request.target_project }
+ let(:merge_request) { create(:merge_request) }
+ let(:project) { merge_request.target_project }
+ let(:user) { project.creator }
before do
project.add_master(user)
- sign_in user
+ sign_in(user)
end
context 'with pipelines' do
@@ -23,7 +23,7 @@ feature 'Pipelines for Merge Requests', :js do
merge_request.update_attribute(:head_pipeline_id, pipeline.id)
end
- scenario 'user visits merge request pipelines tab' do
+ 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')
@@ -36,7 +36,7 @@ feature 'Pipelines for Merge Requests', :js do
expect(page).to have_selector('.stage-cell')
end
- scenario 'pipeline sha does not equal last commit sha' do
+ 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
@@ -51,7 +51,7 @@ feature 'Pipelines for Merge Requests', :js do
visit project_merge_request_path(project, merge_request)
end
- scenario 'user visits merge request page' do
+ it 'user visits merge request page' do
page.within('.merge-request-tabs') do
expect(page).to have_no_link('Pipelines')
end
@@ -60,22 +60,22 @@ feature 'Pipelines for Merge Requests', :js do
end
describe 'race condition' do
- given(:project) { create(:project, :repository) }
- given(:user) { create(:user) }
- given(:build_push_data) { { ref: 'feature', checkout_sha: TestEnv::BRANCH_SHA['feature'] } }
+ let(:project) { create(:project, :repository) }
+ let(:user) { create(:user) }
+ let(:build_push_data) { { ref: 'feature', checkout_sha: TestEnv::BRANCH_SHA['feature'] } }
- given(:merge_request_params) do
+ let(:merge_request_params) do
{ "source_branch" => "feature", "source_project_id" => project.id,
"target_branch" => "master", "target_project_id" => project.id, "title" => "A" }
end
- background do
+ before do
project.add_master(user)
sign_in user
end
context 'when pipeline and merge request were created simultaneously' do
- background do
+ before do
stub_ci_pipeline_to_return_yaml_file
threads = []
@@ -91,7 +91,7 @@ feature 'Pipelines for Merge Requests', :js do
threads.each { |thr| thr.join }
end
- scenario 'user sees pipeline in merge request widget' do
+ it 'user sees pipeline in merge request widget' do
visit project_merge_request_path(project, @merge_request)
expect(page.find(".ci-widget")).to have_content(TestEnv::BRANCH_SHA['feature'])
diff --git a/spec/features/merge_requests/user_sees_system_notes_spec.rb b/spec/features/merge_request/user_sees_system_notes_spec.rb
index 03dc61c2efa..a00a682757d 100644
--- a/spec/features/merge_requests/user_sees_system_notes_spec.rb
+++ b/spec/features/merge_request/user_sees_system_notes_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Merge requests > User sees system notes' do
+describe 'Merge request > User sees system notes' do
let(:public_project) { create(:project, :public, :repository) }
let(:private_project) { create(:project, :private, :repository) }
+ let(:user) { private_project.creator }
let(:issue) { create(:issue, project: private_project) }
let(:merge_request) { create(:merge_request, source_project: public_project, source_branch: 'markdown') }
let!(:note) { create(:note_on_merge_request, :system, noteable: merge_request, project: public_project, note: "mentioned in #{issue.to_reference(public_project)}") }
context 'when logged-in as a member of the private project' do
before do
- user = create(:user)
private_project.add_developer(user)
sign_in(user)
end
diff --git a/spec/features/merge_requests/versions_spec.rb b/spec/features/merge_request/user_sees_versions_spec.rb
index 482f2e51c8b..3a15d70979a 100644
--- a/spec/features/merge_requests/versions_spec.rb
+++ b/spec/features/merge_request/user_sees_versions_spec.rb
@@ -1,15 +1,17 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Merge Request versions', :js do
+describe 'Merge request > User sees versions', :js do
let(:merge_request) { create(:merge_request, importing: true) }
let(:project) { merge_request.source_project }
+ let(:user) { project.creator }
let!(:merge_request_diff1) { merge_request.merge_request_diffs.create(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
let!(:merge_request_diff2) { merge_request.merge_request_diffs.create(head_commit_sha: nil) }
let!(:merge_request_diff3) { merge_request.merge_request_diffs.create(head_commit_sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
- let!(:params) { Hash.new }
+ let!(:params) { {} }
before do
- sign_in(create(:admin))
+ project.add_master(user)
+ sign_in(user)
visit diffs_project_merge_request_path(project, merge_request, params)
end
@@ -62,19 +64,10 @@ feature 'Merge Request versions', :js do
end
end
- it 'should show older version' do
- page.within '.mr-version-dropdown' do
- expect(page).to have_content 'version 1'
- end
-
+ it 'shows comments that were last relevant at that version' do
expect(page).to have_content '5 changed files'
- end
-
- it 'show the message about comments' do
expect(page).to have_content 'Not all comments are displayed'
- end
- it 'shows comments that were last relevant at that version' do
position = Gitlab::Diff::Position.new(
old_path: ".gitmodules",
new_path: ".gitmodules",
@@ -86,7 +79,7 @@ feature 'Merge Request versions', :js do
outdated_diff_note.position = outdated_diff_note.original_position
outdated_diff_note.save!
- visit current_url
+ refresh
expect(page).to have_css(".diffs .notes[data-discussion-id='#{outdated_diff_note.discussion_id}']")
end
@@ -110,26 +103,16 @@ feature 'Merge Request versions', :js do
end
end
- it 'has a path with comparison context' do
+ it 'has a path with comparison context and shows comments that were last relevant at that version' do
expect(page).to have_current_path diffs_project_merge_request_path(
project,
merge_request.iid,
diff_id: merge_request_diff3.id,
start_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
)
- end
-
- it 'should have correct value in the compare dropdown' do
- page.within '.mr-version-compare-dropdown' do
- expect(page).to have_content 'version 1'
- end
- end
-
- it 'show the message about comments' do
+ expect(page).to have_content '4 changed files with 15 additions and 6 deletions'
expect(page).to have_content 'Not all comments are displayed'
- end
- it 'shows comments that were last relevant at that version' do
position = Gitlab::Diff::Position.new(
old_path: ".gitmodules",
new_path: ".gitmodules",
@@ -141,7 +124,7 @@ feature 'Merge Request versions', :js do
outdated_diff_note.position = outdated_diff_note.original_position
outdated_diff_note.save!
- visit current_url
+ refresh
wait_for_requests
expect(page).to have_css(".diffs .notes[data-discussion-id='#{outdated_diff_note.discussion_id}']")
@@ -151,7 +134,7 @@ feature 'Merge Request versions', :js do
expect(page).to have_content '4 changed files with 15 additions and 6 deletions'
end
- it 'should return to latest version when "Show latest version" button is clicked' do
+ it 'returns to latest version when "Show latest version" button is clicked' do
click_link 'Show latest version'
page.within '.mr-version-dropdown' do
expect(page).to have_content 'latest version'
@@ -173,7 +156,7 @@ feature 'Merge Request versions', :js do
end
end
- it 'should have 0 chages between versions' do
+ it 'has 0 chages between versions' do
page.within '.mr-version-compare-dropdown' do
expect(find('.dropdown-toggle')).to have_content 'version 1'
end
@@ -194,7 +177,7 @@ feature 'Merge Request versions', :js do
end
end
- it 'should set the compared versions to be the same' do
+ it 'sets the compared versions to be the same' do
page.within '.mr-version-compare-dropdown' do
expect(find('.dropdown-toggle')).to have_content 'version 2'
end
diff --git a/spec/features/merge_requests/wip_message_spec.rb b/spec/features/merge_request/user_sees_wip_help_message_spec.rb
index 2617e735c25..bc25243244e 100644
--- a/spec/features/merge_requests/wip_message_spec.rb
+++ b/spec/features/merge_request/user_sees_wip_help_message_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Work In Progress help message' do
- let!(:project) { create(:project, :public, :repository) }
- let!(:user) { create(:user) }
+describe 'Merge request > User sees WIP help message' do
+ let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
before do
project.add_master(user)
diff --git a/spec/features/merge_requests/create_new_mr_spec.rb b/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb
index 486555ed5cd..fb73ab05f87 100644
--- a/spec/features/merge_requests/create_new_mr_spec.rb
+++ b/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb
@@ -1,13 +1,12 @@
-require 'spec_helper'
+require 'rails_helper'
-feature 'Create New Merge Request', :js do
- let(:user) { create(:user) }
+describe 'Merge request > User selects branches for new MR', :js do
let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
before do
project.add_master(user)
-
- sign_in user
+ sign_in(user)
end
it 'selects the source branch sha when a tag with the same name exists' do
diff --git a/spec/features/merge_requests/toggle_whitespace_changes_spec.rb b/spec/features/merge_request/user_toggles_whitespace_changes_spec.rb
index fa3d988b27a..2e95a628013 100644
--- a/spec/features/merge_requests/toggle_whitespace_changes_spec.rb
+++ b/spec/features/merge_request/user_toggles_whitespace_changes_spec.rb
@@ -1,10 +1,13 @@
-require 'spec_helper'
+require 'rails_helper'
+
+describe 'Merge request > User toggles whitespace changes', :js do
+ let(:merge_request) { create(:merge_request) }
+ let(:project) { merge_request.project }
+ let(:user) { project.creator }
-feature 'Toggle Whitespace Changes', :js do
before do
- sign_in(create(:admin))
- merge_request = create(:merge_request)
- project = merge_request.source_project
+ project.add_master(user)
+ sign_in(user)
visit diffs_project_merge_request_path(project, merge_request)
end
diff --git a/spec/features/merge_requests/user_uses_slash_commands_spec.rb b/spec/features/merge_request/user_uses_slash_commands_spec.rb
index 5874bf5e187..bd739e69d6c 100644
--- a/spec/features/merge_requests/user_uses_slash_commands_spec.rb
+++ b/spec/features/merge_request/user_uses_slash_commands_spec.rb
@@ -1,8 +1,14 @@
require 'rails_helper'
-feature 'Merge Requests > User uses quick actions', :js do
+describe 'Merge request > User uses quick actions', :js do
include QuickActionsHelpers
+ let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
+ let(:guest) { create(:user) }
+ let(:merge_request) { create(:merge_request, source_project: project) }
+ let!(:milestone) { create(:milestone, project: project, title: 'ASAP') }
+
it_behaves_like 'issuable record that supports quick actions in its description and notes', :merge_request do
let(:issuable) { create(:merge_request, source_project: project) }
let(:new_url_opts) { { merge_request: { source_branch: 'feature', target_branch: 'master' } } }
@@ -20,15 +26,7 @@ feature 'Merge Requests > User uses quick actions', :js do
visit project_merge_request_path(project, merge_request)
end
- after do
- wait_for_requests
- end
-
describe 'time tracking' do
- before do
- visit project_merge_request_path(project, merge_request)
- end
-
it_behaves_like 'issuable time tracker'
end
@@ -56,7 +54,6 @@ feature 'Merge Requests > User uses quick actions', :js do
end
context 'when the current user cannot toggle the WIP prefix' do
- let(:guest) { create(:user) }
before do
project.add_guest(guest)
sign_out(:user)
@@ -102,7 +99,6 @@ feature 'Merge Requests > User uses quick actions', :js do
end
context 'when the current user cannot merge the MR' do
- let(:guest) { create(:user) }
before do
project.add_guest(guest)
sign_out(:user)
@@ -186,7 +182,6 @@ feature 'Merge Requests > User uses quick actions', :js do
end
context 'when current user can not change target branch' do
- let(:guest) { create(:user) }
before do
project.add_guest(guest)
sign_out(:user)
diff --git a/spec/features/merge_requests/assign_issues_spec.rb b/spec/features/merge_requests/assign_issues_spec.rb
deleted file mode 100644
index b2d64a62b4f..00000000000
--- a/spec/features/merge_requests/assign_issues_spec.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-require 'rails_helper'
-
-feature 'Merge request issue assignment', :js do
- let(:user) { create(:user) }
- let(:project) { create(:project, :public, :repository) }
- let(:issue1) { create(:issue, project: project) }
- let(:issue2) { create(:issue, project: project) }
- let(:merge_request) { create(:merge_request, :simple, source_project: project, author: user, description: "fixes #{issue1.to_reference} and #{issue2.to_reference}") }
- let(:service) { MergeRequests::AssignIssuesService.new(merge_request, user, user, project) }
-
- before do
- project.add_developer(user)
- end
-
- def visit_merge_request(current_user = nil)
- sign_in(current_user || user)
- visit project_merge_request_path(project, merge_request)
- end
-
- context 'logged in as author' do
- it 'updates related issues' do
- visit_merge_request
- click_link "Assign yourself to these issues"
-
- expect(page).to have_content "2 issues have been assigned to you"
- end
-
- it 'returns user to the merge request' do
- visit_merge_request
- click_link "Assign yourself to these issues"
-
- expect(page).to have_content merge_request.description
- end
-
- it "doesn't display if related issues are already assigned" do
- [issue1, issue2].each { |issue| issue.update!(assignees: [user]) }
-
- visit_merge_request
-
- expect(page).not_to have_content "Assign yourself"
- end
- end
-
- context 'not MR author' do
- it "doesn't not show assignment link" do
- visit_merge_request(create(:user))
-
- expect(page).not_to have_content "Assign yourself"
- end
- end
-end
diff --git a/spec/features/merge_requests/create_new_mr_from_fork_spec.rb b/spec/features/merge_requests/create_new_mr_from_fork_spec.rb
deleted file mode 100644
index 93c40ff6443..00000000000
--- a/spec/features/merge_requests/create_new_mr_from_fork_spec.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-require 'spec_helper'
-
-feature 'Creating a merge request from a fork', :js do
- include ProjectForksHelper
-
- let(:user) { create(:user) }
- let(:project) { create(:project, :public, :repository) }
- let!(:source_project) do
- fork_project(project, user,
- repository: true,
- namespace: user.namespace)
- end
-
- before do
- source_project.add_master(user)
-
- sign_in(user)
- end
-
- shared_examples 'create merge request to other project' do
- it 'has all possible target projects' do
- visit project_new_merge_request_path(source_project)
-
- first('.js-target-project').click
-
- within('.dropdown-target-project .dropdown-content') do
- expect(page).to have_content(project.full_path)
- expect(page).to have_content(target_project.full_path)
- expect(page).to have_content(source_project.full_path)
- end
- end
-
- it 'allows creating the merge request to another target project' do
- visit project_merge_requests_path(source_project)
-
- page.within '.content' do
- click_link 'New merge request'
- end
-
- find('.js-source-branch', match: :first).click
- find('.dropdown-source-branch .dropdown-content a', match: :first).click
-
- first('.js-target-project').click
- find('.dropdown-target-project .dropdown-content a', text: target_project.full_path).click
-
- click_button 'Compare branches and continue'
-
- wait_for_requests
-
- expect { click_button 'Submit merge request' }
- .to change { target_project.merge_requests.reload.size }.by(1)
- end
-
- it 'updates the branches when selecting a new target project' do
- target_project_member = target_project.owner
- CreateBranchService.new(target_project, target_project_member)
- .execute('a-brand-new-branch-to-test', 'master')
- visit project_new_merge_request_path(source_project)
-
- first('.js-target-project').click
- find('.dropdown-target-project .dropdown-content a', text: target_project.full_path).click
-
- wait_for_requests
-
- first('.js-target-branch').click
-
- within('.dropdown-target-branch .dropdown-content') do
- expect(page).to have_content('a-brand-new-branch-to-test')
- end
- end
- end
-
- context 'creating to the source of a fork' do
- let!(:target_project) { project }
-
- it_behaves_like('create merge request to other project')
- end
-
- context 'creating to a sibling of a fork' do
- let!(:target_project) do
- other_user = create(:user)
- fork_project(project, other_user,
- repository: true,
- namespace: other_user.namespace)
- end
-
- it_behaves_like('create merge request to other project')
- end
-end
diff --git a/spec/features/merge_requests/created_from_fork_spec.rb b/spec/features/merge_requests/created_from_fork_spec.rb
deleted file mode 100644
index 53b62caf743..00000000000
--- a/spec/features/merge_requests/created_from_fork_spec.rb
+++ /dev/null
@@ -1,94 +0,0 @@
-require 'spec_helper'
-
-feature 'Merge request created from fork' do
- include ProjectForksHelper
-
- given(:user) { create(:user) }
- given(:project) { create(:project, :public, :repository) }
- given(:forked_project) { fork_project(project, user, repository: true) }
-
- given!(:merge_request) do
- create(:merge_request_with_diffs, source_project: forked_project,
- target_project: project,
- description: 'Test merge request')
- end
-
- background do
- forked_project.add_master(user)
- sign_in user
- end
-
- scenario 'user can access merge request' do
- visit_merge_request(merge_request)
-
- expect(page).to have_content 'Test merge request'
- end
-
- context 'when a commit comment exists on the merge request' do
- given(:comment) { 'A commit comment' }
- given(:reply) { 'A reply comment' }
-
- background do
- create(:note_on_commit, note: comment,
- project: forked_project,
- commit_id: merge_request.commit_shas.first)
- end
-
- scenario 'user can reply to the comment', :js do
- visit_merge_request(merge_request)
-
- expect(page).to have_content(comment)
-
- page.within('.discussion-notes') do
- find('.btn-text-field').click
- find('#note_note').send_keys(reply)
- find('.comment-btn').click
- end
-
- wait_for_requests
-
- expect(page).to have_content(reply)
- end
- end
-
- context 'source project is deleted' do
- background do
- MergeRequests::MergeService.new(project, user).execute(merge_request)
- forked_project.destroy!
- end
-
- scenario 'user can access merge request', :js do
- visit_merge_request(merge_request)
-
- expect(page).to have_content 'Test merge request'
- expect(page).to have_content "(removed):#{merge_request.source_branch}"
- end
- end
-
- context 'pipeline present in source project' do
- given(:pipeline) do
- create(:ci_pipeline,
- project: forked_project,
- sha: merge_request.diff_head_sha,
- ref: merge_request.source_branch)
- end
-
- background do
- create(:ci_build, pipeline: pipeline, name: 'rspec')
- create(:ci_build, pipeline: pipeline, name: 'spinach')
- end
-
- scenario 'user visits a pipelines page', :js do
- visit_merge_request(merge_request)
- page.within('.merge-request-tabs') { click_link 'Pipelines' }
-
- page.within('.ci-table') do
- expect(page).to have_content pipeline.id
- end
- end
- end
-
- def visit_merge_request(mr)
- visit project_merge_request_path(project, mr)
- end
-end
diff --git a/spec/features/merge_requests/edit_mr_spec.rb b/spec/features/merge_requests/edit_mr_spec.rb
deleted file mode 100644
index 79be2fbf945..00000000000
--- a/spec/features/merge_requests/edit_mr_spec.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-require 'spec_helper'
-
-feature 'Edit Merge Request' do
- let(:user) { create(:user) }
- let(:project) { create(:project, :public, :repository) }
- let(:merge_request) { create(:merge_request, :simple, source_project: project) }
-
- before do
- project.add_master(user)
-
- sign_in user
-
- visit edit_project_merge_request_path(project, merge_request)
- end
-
- context 'editing a MR' do
- it 'has class js-quick-submit in form' do
- expect(page).to have_selector('.js-quick-submit')
- end
-
- it 'warns about version conflict' do
- merge_request.update(title: "New title")
-
- fill_in 'merge_request_title', with: 'bug 345'
- fill_in 'merge_request_description', with: 'bug description'
-
- click_button 'Save changes'
-
- expect(page).to have_content 'Someone edited the merge request the same time you did'
- end
-
- it 'allows to unselect "Remove source branch"', :js do
- merge_request.update(merge_params: { 'force_remove_source_branch' => '1' })
- expect(merge_request.merge_params['force_remove_source_branch']).to be_truthy
-
- visit edit_project_merge_request_path(project, merge_request)
- uncheck 'Remove source branch when merge request is accepted'
-
- click_button 'Save changes'
-
- expect(page).to have_unchecked_field 'remove-source-branch-input'
- expect(page).to have_content 'Remove source branch'
- end
-
- it 'should preserve description textarea height', :js do
- long_description = %q(
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam ac ornare ligula, ut tempus arcu. Etiam ultricies accumsan dolor vitae faucibus. Donec at elit lacus. Mauris orci ante, aliquam quis lorem eget, convallis faucibus arcu. Aenean at pulvinar lacus. Ut viverra quam massa, molestie ornare tortor dignissim a. Suspendisse tristique pellentesque tellus, id lacinia metus elementum id. Nam tristique, arcu rhoncus faucibus viverra, lacus ipsum sagittis ligula, vitae convallis odio lacus a nibh. Ut tincidunt est purus, ac vestibulum augue maximus in. Suspendisse vel erat et mi ultricies semper. Pellentesque volutpat pellentesque consequat.
-
- Cras congue nec ligula tristique viverra. Curabitur fringilla fringilla fringilla. Donec rhoncus dignissim orci ut accumsan. Ut rutrum urna a rhoncus varius. Maecenas blandit, mauris nec accumsan gravida, augue nibh finibus magna, sed maximus turpis libero nec neque. Suspendisse at semper est. Nunc imperdiet dapibus dui, varius sollicitudin erat luctus non. Sed pellentesque ligula eget posuere facilisis. Donec dictum commodo volutpat. Donec egestas dui ac magna sollicitudin bibendum. Vivamus purus neque, ullamcorper ac feugiat et, tempus sit amet metus. Praesent quis viverra neque. Sed bibendum viverra est, eu aliquam mi ornare vitae. Proin et dapibus ipsum. Nunc tortor diam, malesuada nec interdum vel, placerat quis justo. Ut viverra at erat eu laoreet.
-
- Pellentesque commodo, diam sit amet dignissim condimentum, tortor justo pretium est, non venenatis metus eros ut nunc. Etiam ut neque eget sem dapibus aliquam. Curabitur vel elit lorem. Nulla nec enim elit. Sed ut ex id justo facilisis convallis at ac augue. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nullam cursus egestas turpis non tristique. Suspendisse in erat sem. Fusce libero elit, fermentum gravida mauris id, auctor iaculis felis. Nullam vulputate tempor laoreet.
-
- Nam tempor et magna sed convallis. Fusce sit amet sollicitudin risus, a ullamcorper lacus. Morbi gravida quis sem eget porttitor. Donec eu egestas mauris, in elementum tortor. Sed eget ex mi. Mauris iaculis tortor ut est auctor, nec dignissim quam sagittis. Suspendisse vel metus non quam suscipit tincidunt. Cras molestie lacus non justo finibus sodales quis vitae erat. In a porttitor nisi, id sollicitudin urna. Ut at felis tellus. Suspendisse potenti.
-
- Maecenas leo ligula, varius at neque vitae, ornare maximus justo. Nullam convallis luctus risus et vulputate. Duis suscipit faucibus iaculis. Etiam quis tortor faucibus, tristique tellus sit amet, sodales neque. Nulla dapibus nisi vel aliquet consequat. Etiam faucibus, metus eget condimentum iaculis, enim urna lobortis sem, id efficitur eros sapien nec nisi. Aenean ut finibus ex.
- )
-
- fill_in 'merge_request_description', with: long_description
-
- height = get_textarea_height
- find('.js-md-preview-button').click
- find('.js-md-write-button').click
- new_height = get_textarea_height
-
- expect(height).to eq(new_height)
- end
-
- def get_textarea_height
- find('#merge_request_description')
- page.evaluate_script('document.getElementById("merge_request_description").offsetHeight')
- end
- end
-end
diff --git a/spec/features/merge_requests/filter_by_labels_spec.rb b/spec/features/merge_requests/filter_by_labels_spec.rb
deleted file mode 100644
index 7adae08e499..00000000000
--- a/spec/features/merge_requests/filter_by_labels_spec.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-require 'rails_helper'
-
-feature 'Merge Request filtering by Labels', :js do
- include FilteredSearchHelpers
- include MergeRequestHelpers
-
- let(:project) { create(:project, :public, :repository) }
- let!(:user) { create(:user) }
- let!(:label) { create(:label, project: project) }
-
- let!(:bug) { create(:label, project: project, title: 'bug') }
- let!(:feature) { create(:label, project: project, title: 'feature') }
- let!(:enhancement) { create(:label, project: project, title: 'enhancement') }
-
- let!(:mr1) { create(:merge_request, title: "Bugfix1", source_project: project, target_project: project, source_branch: "fix") }
- let!(:mr2) { create(:merge_request, title: "Bugfix2", source_project: project, target_project: project, source_branch: "wip") }
- let!(:mr3) { create(:merge_request, title: "Feature1", source_project: project, target_project: project, source_branch: "improve/awesome") }
-
- before do
- mr1.labels << bug
-
- mr2.labels << bug
- mr2.labels << enhancement
-
- mr3.title = "Feature1"
- mr3.labels << feature
-
- project.add_master(user)
- sign_in(user)
-
- visit project_merge_requests_path(project)
- end
-
- context 'filter by label bug' do
- before do
- input_filtered_search('label:~bug')
- end
-
- it 'apply the filter' do
- expect(page).to have_content "Bugfix1"
- expect(page).to have_content "Bugfix2"
- expect(page).not_to have_content "Feature1"
- end
- end
-
- context 'filter by label feature' do
- before do
- input_filtered_search('label:~feature')
- end
-
- it 'applies the filter' do
- expect(page).to have_content "Feature1"
- expect(page).not_to have_content "Bugfix2"
- expect(page).not_to have_content "Bugfix1"
- end
- end
-
- context 'filter by label enhancement' do
- before do
- input_filtered_search('label:~enhancement')
- end
-
- it 'applies the filter' do
- expect(page).to have_content "Bugfix2"
- expect(page).not_to have_content "Feature1"
- expect(page).not_to have_content "Bugfix1"
- end
- end
-
- context 'filter by label enhancement and bug in issues list' do
- before do
- input_filtered_search('label:~bug label:~enhancement')
- end
-
- it 'applies the filters' do
- expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).to have_content "Bugfix2"
- expect(page).not_to have_content "Feature1"
- end
- end
-
- context 'filter dropdown' do
- it 'filters by label name' do
- init_label_search
- filtered_search.send_keys('~bug')
-
- page.within '.filter-dropdown' do
- expect(page).not_to have_content 'enhancement'
- expect(page).to have_content 'bug'
- end
- end
- end
-end
diff --git a/spec/features/merge_requests/filter_by_milestone_spec.rb b/spec/features/merge_requests/filter_by_milestone_spec.rb
deleted file mode 100644
index 8db94352f73..00000000000
--- a/spec/features/merge_requests/filter_by_milestone_spec.rb
+++ /dev/null
@@ -1,97 +0,0 @@
-require 'rails_helper'
-
-feature 'Merge Request filtering by Milestone' do
- include FilteredSearchHelpers
- include MergeRequestHelpers
-
- let(:project) { create(:project, :public, :repository) }
- let!(:user) { create(:user)}
- let(:milestone) { create(:milestone, project: project) }
-
- def filter_by_milestone(title)
- find(".js-milestone-select").click
- find(".milestone-filter a", text: title).click
- end
-
- before do
- project.add_master(user)
- sign_in(user)
- end
-
- scenario 'filters by no Milestone', :js do
- create(:merge_request, :with_diffs, source_project: project)
- create(:merge_request, :simple, source_project: project, milestone: milestone)
-
- visit_merge_requests(project)
- input_filtered_search('milestone:none')
-
- expect_tokens([milestone_token('none', false)])
- expect_filtered_search_input_empty
-
- expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).to have_css('.merge-request', count: 1)
- end
-
- context 'filters by upcoming milestone', :js do
- it 'does not show merge requests with no expiry' do
- create(:merge_request, :with_diffs, source_project: project)
- create(:merge_request, :simple, source_project: project, milestone: milestone)
-
- visit_merge_requests(project)
- input_filtered_search('milestone:upcoming')
-
- expect(page).to have_css('.merge-request', count: 0)
- end
-
- it 'shows merge requests in future' do
- milestone = create(:milestone, project: project, due_date: Date.tomorrow)
- create(:merge_request, :with_diffs, source_project: project)
- create(:merge_request, :simple, source_project: project, milestone: milestone)
-
- visit_merge_requests(project)
- input_filtered_search('milestone:upcoming')
-
- expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).to have_css('.merge-request', count: 1)
- end
-
- it 'does not show merge requests in past' do
- milestone = create(:milestone, project: project, due_date: Date.yesterday)
- create(:merge_request, :with_diffs, source_project: project)
- create(:merge_request, :simple, source_project: project, milestone: milestone)
-
- visit_merge_requests(project)
- input_filtered_search('milestone:upcoming')
-
- expect(page).to have_css('.merge-request', count: 0)
- end
- end
-
- scenario 'filters by a specific Milestone', :js do
- create(:merge_request, :with_diffs, source_project: project, milestone: milestone)
- create(:merge_request, :simple, source_project: project)
-
- visit_merge_requests(project)
- input_filtered_search("milestone:%'#{milestone.title}'")
-
- expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).to have_css('.merge-request', count: 1)
- end
-
- context 'when milestone has single quotes in title' do
- background do
- milestone.update(name: "rock 'n' roll")
- end
-
- scenario 'filters by a specific Milestone', :js do
- create(:merge_request, :with_diffs, source_project: project, milestone: milestone)
- create(:merge_request, :simple, source_project: project)
-
- visit_merge_requests(project)
- input_filtered_search("milestone:%\"#{milestone.title}\"")
-
- expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).to have_css('.merge-request', count: 1)
- end
- end
-end
diff --git a/spec/features/merge_requests/filter_merge_requests_spec.rb b/spec/features/merge_requests/filter_merge_requests_spec.rb
deleted file mode 100644
index aac295ab940..00000000000
--- a/spec/features/merge_requests/filter_merge_requests_spec.rb
+++ /dev/null
@@ -1,337 +0,0 @@
-require 'rails_helper'
-
-describe 'Filter merge requests' do
- include FilteredSearchHelpers
- include MergeRequestHelpers
-
- let!(:project) { create(:project, :repository) }
- let!(:group) { create(:group) }
- let!(:user) { create(:user) }
- let!(:milestone) { create(:milestone, project: project) }
- let!(:label) { create(:label, project: project) }
- let!(:wontfix) { create(:label, project: project, title: "Won't fix") }
-
- before do
- project.add_master(user)
- group.add_developer(user)
- sign_in(user)
- create(:merge_request, source_project: project, target_project: project)
-
- visit project_merge_requests_path(project)
- end
-
- describe 'for assignee from mr#index' do
- let(:search_query) { "assignee:@#{user.username}" }
-
- def expect_assignee_visual_tokens
- wait_for_requests
-
- expect_tokens([assignee_token(user.name)])
- expect_filtered_search_input_empty
- end
-
- before do
- input_filtered_search(search_query)
-
- expect_mr_list_count(0)
- end
-
- context 'assignee', :js do
- it 'updates to current user' do
- expect_assignee_visual_tokens()
- end
-
- it 'does not change when closed link is clicked' do
- find('.issues-state-filters [data-state="closed"]').click
-
- expect_assignee_visual_tokens()
- end
-
- it 'does not change when all link is clicked' do
- find('.issues-state-filters [data-state="all"]').click
-
- expect_assignee_visual_tokens()
- end
- end
- end
-
- describe 'for milestone from mr#index' do
- let(:search_query) { "milestone:%\"#{milestone.title}\"" }
-
- def expect_milestone_visual_tokens
- expect_tokens([milestone_token("\"#{milestone.title}\"")])
- expect_filtered_search_input_empty
- end
-
- before do
- input_filtered_search(search_query)
-
- expect_mr_list_count(0)
- end
-
- context 'milestone', :js do
- it 'updates to current milestone' do
- expect_milestone_visual_tokens()
- end
-
- it 'does not change when closed link is clicked' do
- find('.issues-state-filters [data-state="closed"]').click
-
- expect_milestone_visual_tokens()
- end
-
- it 'does not change when all link is clicked' do
- find('.issues-state-filters [data-state="all"]').click
-
- expect_milestone_visual_tokens()
- end
- end
- end
-
- describe 'for label from mr#index', :js do
- it 'filters by no label' do
- input_filtered_search('label:none')
-
- expect_mr_list_count(1)
- expect_tokens([label_token('none', false)])
- expect_filtered_search_input_empty
- end
-
- it 'filters by a label' do
- input_filtered_search("label:~#{label.title}")
-
- expect_mr_list_count(0)
- expect_tokens([label_token(label.title)])
- expect_filtered_search_input_empty
- end
-
- it "filters by `won't fix` and another label" do
- input_filtered_search("label:~\"#{wontfix.title}\" label:~#{label.title}")
-
- expect_mr_list_count(0)
- expect_tokens([label_token("\"#{wontfix.title}\""), label_token(label.title)])
- expect_filtered_search_input_empty
- end
-
- it "filters by `won't fix` label followed by another label after page load" do
- input_filtered_search("label:~\"#{wontfix.title}\"")
-
- expect_mr_list_count(0)
- expect_tokens([label_token("\"#{wontfix.title}\"")])
- expect_filtered_search_input_empty
-
- input_filtered_search_keys("label:~#{label.title}")
-
- expect_mr_list_count(0)
- expect_tokens([label_token("\"#{wontfix.title}\""), label_token(label.title)])
- expect_filtered_search_input_empty
- end
- end
-
- describe 'for assignee and label from mr#index' do
- let(:search_query) { "assignee:@#{user.username} label:~#{label.title}" }
-
- before do
- input_filtered_search(search_query)
-
- expect_mr_list_count(0)
- end
-
- context 'assignee and label', :js do
- def expect_assignee_label_visual_tokens
- wait_for_requests
-
- expect_tokens([assignee_token(user.name), label_token(label.title)])
- expect_filtered_search_input_empty
- end
-
- it 'updates to current assignee and label' do
- expect_assignee_label_visual_tokens()
- end
-
- it 'does not change when closed link is clicked' do
- find('.issues-state-filters [data-state="closed"]').click
-
- expect_assignee_label_visual_tokens()
- end
-
- it 'does not change when all link is clicked' do
- find('.issues-state-filters [data-state="all"]').click
-
- expect_assignee_label_visual_tokens()
- end
- end
- end
-
- describe 'filter merge requests by text' do
- before do
- create(:merge_request, title: "Bug", source_project: project, target_project: project, source_branch: "wip")
-
- bug_label = create(:label, project: project, title: 'bug')
- milestone = create(:milestone, title: "8", project: project)
-
- mr = create(:merge_request,
- title: "Bug 2",
- source_project: project,
- target_project: project,
- source_branch: "fix",
- milestone: milestone,
- author: user,
- assignee: user)
- mr.labels << bug_label
-
- visit project_merge_requests_path(project)
- end
-
- context 'only text', :js do
- it 'filters merge requests by searched text' do
- input_filtered_search('bug')
-
- expect_mr_list_count(2)
- end
-
- it 'does not show any merge requests' do
- input_filtered_search('testing')
-
- page.within '.mr-list' do
- expect(page).not_to have_selector('.merge-request')
- end
- end
- end
-
- context 'filters and searches', :js do
- it 'filters by text and label' do
- input_filtered_search('Bug')
-
- expect_mr_list_count(2)
- expect_filtered_search_input('Bug')
-
- input_filtered_search_keys(' label:~bug')
-
- expect_mr_list_count(1)
- expect_tokens([label_token('bug')])
- expect_filtered_search_input('Bug')
- end
-
- it 'filters by text and milestone' do
- input_filtered_search('Bug')
-
- expect_mr_list_count(2)
- expect_filtered_search_input('Bug')
-
- input_filtered_search_keys(' milestone:%8')
-
- expect_mr_list_count(1)
- expect_tokens([milestone_token('8')])
- expect_filtered_search_input('Bug')
- end
-
- it 'filters by text and assignee' do
- input_filtered_search('Bug')
-
- expect_mr_list_count(2)
- expect_filtered_search_input('Bug')
-
- input_filtered_search_keys(" assignee:@#{user.username}")
-
- expect_mr_list_count(1)
-
- wait_for_requests
-
- expect_tokens([assignee_token(user.name)])
- expect_filtered_search_input('Bug')
- end
-
- it 'filters by text and author' do
- input_filtered_search('Bug')
-
- expect_mr_list_count(2)
- expect_filtered_search_input('Bug')
-
- input_filtered_search_keys(" author:@#{user.username}")
-
- wait_for_requests
-
- expect_mr_list_count(1)
- expect_tokens([author_token(user.name)])
- expect_filtered_search_input('Bug')
- end
- end
- end
-
- describe 'filter merge requests and sort', :js do
- before do
- bug_label = create(:label, project: project, title: 'bug')
-
- mr1 = create(:merge_request, title: "Frontend", source_project: project, target_project: project, source_branch: "wip")
- mr2 = create(:merge_request, title: "Bug 2", source_project: project, target_project: project, source_branch: "fix")
-
- mr1.labels << bug_label
- mr2.labels << bug_label
-
- visit project_merge_requests_path(project)
- end
-
- it 'is able to filter and sort merge requests' do
- input_filtered_search('label:~bug')
-
- expect_mr_list_count(2)
-
- click_button 'Created date'
- page.within '.dropdown-menu-sort' do
- click_link 'Priority'
- end
- wait_for_requests
-
- page.within '.mr-list' do
- expect(page).to have_content('Frontend')
- end
- end
- end
-
- describe 'filter by assignee id', :js do
- it 'filter by current user' do
- visit project_merge_requests_path(project, assignee_id: user.id)
-
- wait_for_requests
-
- expect_tokens([assignee_token(user.name)])
- expect_filtered_search_input_empty
- end
-
- it 'filter by new user' do
- new_user = create(:user)
- project.add_developer(new_user)
-
- visit project_merge_requests_path(project, assignee_id: new_user.id)
-
- wait_for_requests
-
- expect_tokens([assignee_token(new_user.name)])
- expect_filtered_search_input_empty
- end
- end
-
- describe 'filter by author id', :js do
- it 'filter by current user' do
- visit project_merge_requests_path(project, author_id: user.id)
-
- wait_for_requests
-
- expect_tokens([author_token(user.name)])
- expect_filtered_search_input_empty
- end
-
- it 'filter by new user' do
- new_user = create(:user)
- project.add_developer(new_user)
-
- visit project_merge_requests_path(project, author_id: new_user.id)
-
- wait_for_requests
-
- expect_tokens([author_token(new_user.name)])
- expect_filtered_search_input_empty
- end
- end
-end
diff --git a/spec/features/merge_requests/filters_generic_behavior_spec.rb b/spec/features/merge_requests/filters_generic_behavior_spec.rb
new file mode 100644
index 00000000000..0e7fac6b409
--- /dev/null
+++ b/spec/features/merge_requests/filters_generic_behavior_spec.rb
@@ -0,0 +1,81 @@
+require 'rails_helper'
+
+describe 'Merge Requests > Filters generic behavior', :js do
+ include FilteredSearchHelpers
+
+ let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
+ let(:bug) { create(:label, project: project, title: 'bug') }
+ let(:open_mr) { create(:merge_request, title: 'Bugfix1', source_project: project, target_project: project, source_branch: 'bugfix1') }
+ let(:merged_mr) { create(:merge_request, :merged, title: 'Bugfix2', source_project: project, target_project: project, source_branch: 'bugfix2') }
+ let(:closed_mr) { create(:merge_request, :closed, title: 'Feature', source_project: project, target_project: project, source_branch: 'improve/awesome') }
+
+ before do
+ open_mr.labels << bug
+ merged_mr.labels << bug
+ closed_mr.labels << bug
+
+ sign_in(user)
+ visit project_merge_requests_path(project)
+ end
+
+ context 'when filtered by a label' do
+ before do
+ input_filtered_search('label:~bug')
+ end
+
+ describe 'state tabs' do
+ it 'does not change when state tabs are clicked' do
+ expect(page).to have_issuable_counts(open: 1, merged: 1, closed: 1, all: 3)
+ expect(page).to have_content 'Bugfix1'
+ expect(page).not_to have_content 'Bugfix2'
+ expect(page).not_to have_content 'Feature'
+
+ find('.issues-state-filters [data-state="merged"]').click
+
+ expect(page).to have_issuable_counts(open: 1, merged: 1, closed: 1, all: 3)
+ expect(page).not_to have_content 'Bugfix1'
+ expect(page).to have_content 'Bugfix2'
+ expect(page).not_to have_content 'Feature'
+
+ find('.issues-state-filters [data-state="closed"]').click
+
+ expect(page).to have_issuable_counts(open: 1, merged: 1, closed: 1, all: 3)
+ expect(page).not_to have_content 'Bugfix1'
+ expect(page).not_to have_content 'Bugfix2'
+ expect(page).to have_content 'Feature'
+
+ find('.issues-state-filters [data-state="all"]').click
+
+ expect(page).to have_issuable_counts(open: 1, merged: 1, closed: 1, all: 3)
+ expect(page).to have_content 'Bugfix1'
+ expect(page).to have_content 'Bugfix2'
+ expect(page).to have_content 'Feature'
+ end
+ end
+
+ describe 'clear button' do
+ it 'allows user to remove filtered labels' do
+ first('.clear-search').click
+ filtered_search.send_keys(:enter)
+
+ expect(page).to have_issuable_counts(open: 1, merged: 1, closed: 1, all: 3)
+ expect(page).to have_content 'Bugfix1'
+ expect(page).not_to have_content 'Bugfix2'
+ expect(page).not_to have_content 'Feature'
+ end
+ end
+ end
+
+ context 'filter dropdown' do
+ it 'filters by label name' do
+ init_label_search
+ filtered_search.send_keys('~bug')
+
+ page.within '.filter-dropdown' do
+ expect(page).not_to have_content 'enhancement'
+ expect(page).to have_content 'bug'
+ end
+ end
+ end
+end
diff --git a/spec/features/merge_requests/form_spec.rb b/spec/features/merge_requests/form_spec.rb
deleted file mode 100644
index 1ebf762a006..00000000000
--- a/spec/features/merge_requests/form_spec.rb
+++ /dev/null
@@ -1,301 +0,0 @@
-require 'rails_helper'
-
-describe 'New/edit merge request', :js do
- include ProjectForksHelper
-
- let!(:project) { create(:project, :public, :repository) }
- let(:forked_project) { fork_project(project, nil, repository: true) }
- let!(:user) { create(:user) }
- let!(:user2) { create(:user) }
- let!(:milestone) { create(:milestone, project: project) }
- let!(:label) { create(:label, project: project) }
- let!(:label2) { create(:label, project: project) }
-
- before do
- project.add_master(user)
- project.add_master(user2)
- end
-
- context 'owned projects' do
- before do
- sign_in(user)
- end
-
- context 'new merge request' do
- before do
- visit project_new_merge_request_path(
- project,
- merge_request: {
- source_project_id: project.id,
- target_project_id: project.id,
- source_branch: 'fix',
- target_branch: 'master'
- })
- end
-
- it 'creates new merge request' do
- click_button 'Assignee'
- page.within '.dropdown-menu-user' do
- click_link user2.name
- end
- expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user2.id.to_s)
- page.within '.js-assignee-search' do
- expect(page).to have_content user2.name
- end
-
- find('a', text: 'Assign to me').click
- expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)
- page.within '.js-assignee-search' do
- expect(page).to have_content user.name
- end
-
- click_button 'Milestone'
- page.within '.issue-milestone' do
- click_link milestone.title
- end
- expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
- page.within '.js-milestone-select' do
- expect(page).to have_content milestone.title
- end
-
- click_button 'Labels'
- page.within '.dropdown-menu-labels' do
- click_link label.title
- click_link label2.title
- end
- page.within '.js-label-select' do
- expect(page).to have_content label.title
- end
- expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
- expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
-
- click_button 'Submit merge request'
-
- page.within '.issuable-sidebar' do
- page.within '.assignee' do
- expect(page).to have_content user.name
- end
-
- page.within '.milestone' do
- expect(page).to have_content milestone.title
- end
-
- page.within '.labels' do
- expect(page).to have_content label.title
- expect(page).to have_content label2.title
- end
- end
-
- page.within '.breadcrumbs' do
- merge_request = MergeRequest.find_by(source_branch: 'fix')
-
- expect(page).to have_text("Merge Requests #{merge_request.to_reference}")
- end
- end
-
- it 'description has autocomplete' do
- find('#merge_request_description').native.send_keys('')
- fill_in 'merge_request_description', with: '@'
-
- expect(page).to have_selector('.atwho-view')
- end
- end
-
- context 'edit merge request' do
- before do
- merge_request = create(:merge_request,
- source_project: project,
- target_project: project,
- source_branch: 'fix',
- target_branch: 'master'
- )
-
- visit edit_project_merge_request_path(project, merge_request)
- end
-
- it 'updates merge request' do
- click_button 'Assignee'
- page.within '.dropdown-menu-user' do
- click_link user.name
- end
- expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)
- page.within '.js-assignee-search' do
- expect(page).to have_content user.name
- end
-
- click_button 'Milestone'
- page.within '.issue-milestone' do
- click_link milestone.title
- end
- expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
- page.within '.js-milestone-select' do
- expect(page).to have_content milestone.title
- end
-
- click_button 'Labels'
- page.within '.dropdown-menu-labels' do
- click_link label.title
- click_link label2.title
- end
- expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
- expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
- page.within '.js-label-select' do
- expect(page).to have_content label.title
- end
-
- click_button 'Save changes'
-
- page.within '.issuable-sidebar' do
- page.within '.assignee' do
- expect(page).to have_content user.name
- end
-
- page.within '.milestone' do
- expect(page).to have_content milestone.title
- end
-
- page.within '.labels' do
- expect(page).to have_content label.title
- expect(page).to have_content label2.title
- end
- end
- end
-
- it 'description has autocomplete' do
- find('#merge_request_description').native.send_keys('')
- fill_in 'merge_request_description', with: '@'
-
- expect(page).to have_selector('.atwho-view')
- end
- end
- end
-
- context 'forked project' do
- before do
- forked_project.add_master(user)
- sign_in(user)
- end
-
- context 'new merge request' do
- before do
- visit project_new_merge_request_path(
- forked_project,
- merge_request: {
- source_project_id: forked_project.id,
- target_project_id: project.id,
- source_branch: 'fix',
- target_branch: 'master'
- })
- end
-
- it 'creates new merge request' do
- click_button 'Assignee'
- page.within '.dropdown-menu-user' do
- click_link user.name
- end
- expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)
- page.within '.js-assignee-search' do
- expect(page).to have_content user.name
- end
-
- click_button 'Milestone'
- page.within '.issue-milestone' do
- click_link milestone.title
- end
- expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
- page.within '.js-milestone-select' do
- expect(page).to have_content milestone.title
- end
-
- click_button 'Labels'
- page.within '.dropdown-menu-labels' do
- click_link label.title
- click_link label2.title
- end
- page.within '.js-label-select' do
- expect(page).to have_content label.title
- end
- expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
- expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
-
- click_button 'Submit merge request'
-
- page.within '.issuable-sidebar' do
- page.within '.assignee' do
- expect(page).to have_content user.name
- end
-
- page.within '.milestone' do
- expect(page).to have_content milestone.title
- end
-
- page.within '.labels' do
- expect(page).to have_content label.title
- expect(page).to have_content label2.title
- end
- end
- end
- end
-
- context 'edit merge request' do
- before do
- merge_request = create(:merge_request,
- source_project: forked_project,
- target_project: project,
- source_branch: 'fix',
- target_branch: 'master'
- )
-
- visit edit_project_merge_request_path(project, merge_request)
- end
-
- it 'should update merge request' do
- click_button 'Assignee'
- page.within '.dropdown-menu-user' do
- click_link user.name
- end
- expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)
- page.within '.js-assignee-search' do
- expect(page).to have_content user.name
- end
-
- click_button 'Milestone'
- page.within '.issue-milestone' do
- click_link milestone.title
- end
- expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
- page.within '.js-milestone-select' do
- expect(page).to have_content milestone.title
- end
-
- click_button 'Labels'
- page.within '.dropdown-menu-labels' do
- click_link label.title
- click_link label2.title
- end
- expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
- expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
- page.within '.js-label-select' do
- expect(page).to have_content label.title
- end
-
- click_button 'Save changes'
-
- page.within '.issuable-sidebar' do
- page.within '.assignee' do
- expect(page).to have_content user.name
- end
-
- page.within '.milestone' do
- expect(page).to have_content milestone.title
- end
-
- page.within '.labels' do
- expect(page).to have_content label.title
- expect(page).to have_content label2.title
- end
- end
- end
- end
- end
-end
diff --git a/spec/features/merge_requests/reset_filters_spec.rb b/spec/features/merge_requests/reset_filters_spec.rb
deleted file mode 100644
index daca4422bf1..00000000000
--- a/spec/features/merge_requests/reset_filters_spec.rb
+++ /dev/null
@@ -1,136 +0,0 @@
-require 'rails_helper'
-
-feature 'Merge requests filter clear button', :js do
- include FilteredSearchHelpers
- include MergeRequestHelpers
- include IssueHelpers
-
- let!(:project) { create(:project, :public, :repository) }
- let!(:user) { create(:user) }
- let!(:milestone) { create(:milestone, project: project) }
- let!(:bug) { create(:label, project: project, name: 'bug')}
- let!(:mr1) { create(:merge_request, title: "Feature", source_project: project, target_project: project, source_branch: "improve/awesome", milestone: milestone, author: user, assignee: user) }
- let!(:mr2) { create(:merge_request, title: "Bugfix1", source_project: project, target_project: project, source_branch: "fix") }
-
- let(:merge_request_css) { '.merge-request' }
- let(:clear_search_css) { '.filtered-search-box .clear-search' }
-
- before do
- mr2.labels << bug
- project.add_developer(user)
- end
-
- context 'when a milestone filter has been applied' do
- it 'resets the milestone filter' do
- visit_merge_requests(project, milestone_title: milestone.title)
-
- expect(page).to have_css(merge_request_css, count: 1)
- expect(get_filtered_search_placeholder).to eq('')
-
- reset_filters
-
- expect(page).to have_css(merge_request_css, count: 2)
- expect(get_filtered_search_placeholder).to eq(default_placeholder)
- end
- end
-
- context 'when a label filter has been applied' do
- it 'resets the label filter' do
- visit_merge_requests(project, label_name: bug.name)
-
- expect(page).to have_css(merge_request_css, count: 1)
- expect(get_filtered_search_placeholder).to eq('')
-
- reset_filters
-
- expect(page).to have_css(merge_request_css, count: 2)
- expect(get_filtered_search_placeholder).to eq(default_placeholder)
- end
- end
-
- context 'when multiple label filters have been applied' do
- let!(:label) { create(:label, project: project, name: 'Frontend') }
- let(:filter_dropdown) { find("#js-dropdown-label .filter-dropdown") }
-
- before do
- visit_merge_requests(project)
- init_label_search
- end
-
- it 'filters bug label' do
- filtered_search.set('~bug')
-
- filter_dropdown.find('.filter-dropdown-item', text: bug.title).click
- init_label_search
-
- expect(filter_dropdown.find('.filter-dropdown-item', text: bug.title)).to be_visible
- expect(filter_dropdown.find('.filter-dropdown-item', text: label.title)).to be_visible
- end
- end
-
- context 'when a text search has been conducted' do
- it 'resets the text search filter' do
- visit_merge_requests(project, search: 'Bug')
-
- expect(page).to have_css(merge_request_css, count: 1)
- expect(get_filtered_search_placeholder).to eq('')
-
- reset_filters
-
- expect(page).to have_css(merge_request_css, count: 2)
- expect(get_filtered_search_placeholder).to eq(default_placeholder)
- end
- end
-
- context 'when author filter has been applied' do
- it 'resets the author filter' do
- visit_merge_requests(project, author_username: user.username)
-
- expect(page).to have_css(merge_request_css, count: 1)
- expect(get_filtered_search_placeholder).to eq('')
-
- reset_filters
-
- expect(page).to have_css(merge_request_css, count: 2)
- expect(get_filtered_search_placeholder).to eq(default_placeholder)
- end
- end
-
- context 'when assignee filter has been applied' do
- it 'resets the assignee filter' do
- visit_merge_requests(project, assignee_username: user.username)
-
- expect(page).to have_css(merge_request_css, count: 1)
- expect(get_filtered_search_placeholder).to eq('')
-
- reset_filters
-
- expect(page).to have_css(merge_request_css, count: 2)
- expect(get_filtered_search_placeholder).to eq(default_placeholder)
- end
- end
-
- context 'when all filters have been applied' do
- it 'clears all filters' do
- visit_merge_requests(project, assignee_username: user.username, author_username: user.username, milestone_title: milestone.title, label_name: bug.name, search: 'Bug')
-
- expect(page).to have_css(merge_request_css, count: 0)
- expect(get_filtered_search_placeholder).to eq('')
-
- reset_filters
-
- expect(page).to have_css(merge_request_css, count: 2)
- expect(get_filtered_search_placeholder).to eq(default_placeholder)
- end
- end
-
- context 'when no filters have been applied' do
- it 'the clear button should not be visible' do
- visit_merge_requests(project)
-
- expect(page).to have_css(merge_request_css, count: 2)
- expect(get_filtered_search_placeholder).to eq(default_placeholder)
- expect(page).not_to have_css(clear_search_css)
- end
- end
-end
diff --git a/spec/features/merge_requests/target_branch_spec.rb b/spec/features/merge_requests/target_branch_spec.rb
deleted file mode 100644
index d9f7a056dea..00000000000
--- a/spec/features/merge_requests/target_branch_spec.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-require 'spec_helper'
-
-describe 'Target branch', :js do
- let(:user) { create(:user) }
- let(:merge_request) { create(:merge_request) }
- let(:project) { merge_request.project }
-
- def path_to_merge_request
- project_merge_request_path(project, merge_request)
- end
-
- before do
- sign_in user
- project.add_master(user)
- end
-
- context 'when branch was deleted' do
- before do
- DeleteBranchService.new(project, user).execute('feature')
- visit path_to_merge_request
- end
-
- it 'shows a message about missing target branch' do
- expect(page).to have_content(
- 'Target branch does not exist'
- )
- end
-
- it 'does not show link to target branch' do
- expect(page).not_to have_selector('.mr-widget-body .js-branch-text a')
- end
- end
-end
diff --git a/spec/features/merge_requests/toggler_behavior_spec.rb b/spec/features/merge_requests/toggler_behavior_spec.rb
deleted file mode 100644
index cd92ad22267..00000000000
--- a/spec/features/merge_requests/toggler_behavior_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'spec_helper'
-
-feature 'toggler_behavior', :js do
- let(:user) { create(:user) }
- let(:project) { create(:project, :repository) }
- let(:merge_request) { create(:merge_request, source_project: project, author: user) }
- let(:note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project) }
- let(:fragment_id) { "#note_#{note.id}" }
-
- before do
- sign_in(create(:admin))
- project = merge_request.source_project
- page.current_window.resize_to(1000, 300)
- visit "#{project_merge_request_path(project, merge_request)}#{fragment_id}"
- end
-
- describe 'scroll position' do
- it 'should be scrolled down to fragment' do
- page_height = page.current_window.size[1]
- page_scroll_y = page.evaluate_script("window.scrollY")
- fragment_position_top = page.evaluate_script("Math.round($('#{fragment_id}').offset().top)")
- expect(find('.js-toggle-content').visible?).to eq true
- expect(find(fragment_id).visible?).to eq true
- expect(fragment_position_top).to be >= page_scroll_y
- expect(fragment_position_top).to be < (page_scroll_y + page_height)
- end
- end
-end
diff --git a/spec/features/merge_requests/user_filters_by_assignees_spec.rb b/spec/features/merge_requests/user_filters_by_assignees_spec.rb
new file mode 100644
index 00000000000..d6c770c93f1
--- /dev/null
+++ b/spec/features/merge_requests/user_filters_by_assignees_spec.rb
@@ -0,0 +1,36 @@
+require 'rails_helper'
+
+describe 'Merge Requests > User filters by assignees', :js do
+ include FilteredSearchHelpers
+
+ let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
+
+ before do
+ create(:merge_request, assignee: user, title: 'Bugfix1', source_project: project, target_project: project, source_branch: 'bugfix1')
+ create(:merge_request, title: 'Bugfix2', source_project: project, target_project: project, source_branch: 'bugfix2')
+
+ sign_in(user)
+ visit project_merge_requests_path(project)
+ end
+
+ context 'filtering by assignee:none' do
+ it 'applies the filter' do
+ input_filtered_search('assignee:none')
+
+ expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
+ expect(page).not_to have_content 'Bugfix1'
+ expect(page).to have_content 'Bugfix2'
+ end
+ end
+
+ context 'filtering by assignee:@username' do
+ it 'applies the filter' do
+ input_filtered_search("assignee:@#{user.username}")
+
+ expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
+ expect(page).to have_content 'Bugfix1'
+ expect(page).not_to have_content 'Bugfix2'
+ end
+ end
+end
diff --git a/spec/features/merge_requests/user_filters_by_labels_spec.rb b/spec/features/merge_requests/user_filters_by_labels_spec.rb
new file mode 100644
index 00000000000..08d741af93d
--- /dev/null
+++ b/spec/features/merge_requests/user_filters_by_labels_spec.rb
@@ -0,0 +1,49 @@
+require 'rails_helper'
+
+describe 'Merge Requests > User filters by labels', :js do
+ include FilteredSearchHelpers
+
+ let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
+ let(:mr1) { create(:merge_request, title: 'Bugfix1', source_project: project, target_project: project, source_branch: 'bugfix1') }
+ let(:mr2) { create(:merge_request, title: 'Bugfix2', source_project: project, target_project: project, source_branch: 'bugfix2') }
+
+ before do
+ bug_label = create(:label, project: project, title: 'bug')
+ enhancement_label = create(:label, project: project, title: 'enhancement')
+ mr1.labels << bug_label
+ mr2.labels << bug_label << enhancement_label
+
+ sign_in(user)
+ visit project_merge_requests_path(project)
+ end
+
+ context 'filtering by label:none' do
+ it 'applies the filter' do
+ input_filtered_search('label:none')
+
+ expect(page).to have_issuable_counts(open: 0, closed: 0, all: 0)
+ expect(page).not_to have_content 'Bugfix1'
+ expect(page).not_to have_content 'Bugfix2'
+ end
+ end
+
+ context 'filtering by label:~enhancement' do
+ it 'applies the filter' do
+ input_filtered_search('label:~enhancement')
+
+ expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
+ expect(page).to have_content 'Bugfix2'
+ expect(page).not_to have_content 'Bugfix1'
+ end
+ end
+
+ context 'filtering by label:~enhancement and label:~bug' do
+ it 'applies the filters' do
+ input_filtered_search('label:~bug label:~enhancement')
+
+ expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
+ expect(page).to have_content 'Bugfix2'
+ end
+ end
+end
diff --git a/spec/features/merge_requests/user_filters_by_milestones_spec.rb b/spec/features/merge_requests/user_filters_by_milestones_spec.rb
new file mode 100644
index 00000000000..727a236d980
--- /dev/null
+++ b/spec/features/merge_requests/user_filters_by_milestones_spec.rb
@@ -0,0 +1,62 @@
+require 'rails_helper'
+
+describe 'Merge Requests > User filters by milestones', :js do
+ include FilteredSearchHelpers
+
+ let(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
+ let(:milestone) { create(:milestone, project: project) }
+
+ before do
+ create(:merge_request, :with_diffs, source_project: project)
+ create(:merge_request, :simple, source_project: project, milestone: milestone)
+
+ sign_in(user)
+ visit project_merge_requests_path(project)
+ end
+
+ it 'filters by no milestone' do
+ input_filtered_search('milestone:none')
+
+ expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
+ expect(page).to have_css('.merge-request', count: 1)
+ end
+
+ it 'filters by a specific milestone' do
+ input_filtered_search("milestone:%'#{milestone.title}'")
+
+ expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
+ expect(page).to have_css('.merge-request', count: 1)
+ end
+
+ describe 'filters by upcoming milestone' do
+ it 'does not show merge requests with no expiry' do
+ input_filtered_search('milestone:upcoming')
+
+ expect(page).to have_issuable_counts(open: 0, closed: 0, all: 0)
+ expect(page).to have_css('.merge-request', count: 0)
+ end
+
+ context 'with an upcoming milestone' do
+ let(:milestone) { create(:milestone, project: project, due_date: Date.tomorrow) }
+
+ it 'shows merge requests' do
+ input_filtered_search('milestone:upcoming')
+
+ expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
+ expect(page).to have_css('.merge-request', count: 1)
+ end
+ end
+
+ context 'with a due milestone' do
+ let(:milestone) { create(:milestone, project: project, due_date: Date.yesterday) }
+
+ it 'does not show any merge requests' do
+ input_filtered_search('milestone:upcoming')
+
+ expect(page).to have_issuable_counts(open: 0, closed: 0, all: 0)
+ expect(page).to have_css('.merge-request', count: 0)
+ end
+ end
+ end
+end
diff --git a/spec/features/merge_requests/user_filters_by_multiple_criteria_spec.rb b/spec/features/merge_requests/user_filters_by_multiple_criteria_spec.rb
new file mode 100644
index 00000000000..1615899a047
--- /dev/null
+++ b/spec/features/merge_requests/user_filters_by_multiple_criteria_spec.rb
@@ -0,0 +1,38 @@
+require 'rails_helper'
+
+describe 'Merge requests > User filters by multiple criteria', :js do
+ include FilteredSearchHelpers
+
+ let!(:project) { create(:project, :public, :repository) }
+ let(:user) { project.creator }
+ let!(:milestone) { create(:milestone, title: 'v1.1', project: project) }
+ let!(:wontfix) { create(:label, project: project, title: "Won't fix") }
+
+ before do
+ sign_in(user)
+ mr = create(:merge_request, title: 'Bugfix2', author: user, assignee: user, source_project: project, target_project: project, milestone: milestone)
+ mr.labels << wontfix
+
+ visit project_merge_requests_path(project)
+ end
+
+ describe 'filtering by label:~"Won\'t fix" and assignee:~bug' do
+ it 'applies the filters' do
+ input_filtered_search("label:~\"Won't fix\" assignee:@#{user.username}")
+
+ expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
+ expect(page).to have_content 'Bugfix2'
+ expect_filtered_search_input_empty
+ end
+ end
+
+ describe 'filtering by text, author, assignee, milestone, and label' do
+ it 'filters by text, author, assignee, milestone, and label' do
+ input_filtered_search_keys("author:@#{user.username} assignee:@#{user.username} milestone:%\"v1.1\" label:~\"Won't fix\" Bug")
+
+ expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
+ expect(page).to have_content 'Bugfix2'
+ expect_filtered_search_input('Bug')
+ end
+ end
+end
diff --git a/spec/features/merge_requests/user_lists_merge_requests_spec.rb b/spec/features/merge_requests/user_lists_merge_requests_spec.rb
index 416a0f78a45..ef7ae490b0f 100644
--- a/spec/features/merge_requests/user_lists_merge_requests_spec.rb
+++ b/spec/features/merge_requests/user_lists_merge_requests_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require 'rails_helper'
-describe 'Projects > Merge requests > User lists merge requests' do
+describe 'Merge requests > User lists merge requests' do
include MergeRequestHelpers
include SortingHelper
diff --git a/spec/features/merge_requests/update_merge_requests_spec.rb b/spec/features/merge_requests/user_mass_updates_spec.rb
index a96404b86ed..199ba7e87ad 100644
--- a/spec/features/merge_requests/update_merge_requests_spec.rb
+++ b/spec/features/merge_requests/user_mass_updates_spec.rb
@@ -1,8 +1,8 @@
require 'rails_helper'
-feature 'Multiple merge requests updating from merge_requests#index' do
- let!(:user) { create(:user)}
- let!(:project) { create(:project, :repository) }
+describe 'Merge requests > User mass updates', :js do
+ let(:project) { create(:project, :repository) }
+ let(:user) { project.creator }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
before do
@@ -10,7 +10,7 @@ feature 'Multiple merge requests updating from merge_requests#index' do
sign_in(user)
end
- context 'status', :js do
+ context 'status' do
describe 'close merge request' do
before do
visit project_merge_requests_path(project)
@@ -37,13 +37,13 @@ feature 'Multiple merge requests updating from merge_requests#index' do
end
end
- context 'assignee', :js do
+ context 'assignee' do
describe 'set assignee' do
before do
visit project_merge_requests_path(project)
end
- it "updates merge request with assignee" do
+ it 'updates merge request with assignee' do
change_assignee(user.name)
page.within('.merge-request .controls') do
@@ -59,7 +59,7 @@ feature 'Multiple merge requests updating from merge_requests#index' do
visit project_merge_requests_path(project)
end
- it "removes assignee from the merge request" do
+ it 'removes assignee from the merge request' do
change_assignee('Unassigned')
expect(find('.merge-request .controls')).not_to have_css('.author_link')
@@ -67,7 +67,7 @@ feature 'Multiple merge requests updating from merge_requests#index' do
end
end
- context 'milestone', :js do
+ context 'milestone' do
let(:milestone) { create(:milestone, project: project) }
describe 'set milestone' do
@@ -75,7 +75,7 @@ feature 'Multiple merge requests updating from merge_requests#index' do
visit project_merge_requests_path(project)
end
- it "updates merge request with milestone" do
+ it 'updates merge request with milestone' do
change_milestone(milestone.title)
expect(find('.merge-request')).to have_content milestone.title
@@ -89,7 +89,7 @@ feature 'Multiple merge requests updating from merge_requests#index' do
visit project_merge_requests_path(project)
end
- it "removes milestone from the merge request" do
+ it 'removes milestone from the merge request' do
change_milestone("No Milestone")
expect(find('.merge-request')).not_to have_content milestone.title
diff --git a/spec/features/merge_requests/widget_deployments_spec.rb b/spec/features/merge_requests/widget_deployments_spec.rb
deleted file mode 100644
index ec2da72ddff..00000000000
--- a/spec/features/merge_requests/widget_deployments_spec.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-require 'spec_helper'
-
-feature 'Widget Deployments Header', :js do
- describe 'when deployed to an environment' do
- given(:user) { create(:user) }
- given(:project) { merge_request.target_project }
- given(:merge_request) { create(:merge_request, :merged) }
- given(:environment) { create(:environment, project: project) }
- given(:role) { :developer }
- given(:sha) { project.commit('master').id }
- given!(:deployment) { create(:deployment, environment: environment, sha: sha) }
- given!(:manual) { }
-
- background do
- sign_in(user)
- project.add_role(user, role)
- visit project_merge_request_path(project, merge_request)
- end
-
- scenario 'displays that the environment is deployed' do
- wait_for_requests
-
- expect(page).to have_content("Deployed to #{environment.name}")
- expect(find('.js-deploy-time')['data-title']).to eq(deployment.created_at.to_time.in_time_zone.to_s(:medium))
- end
-
- context 'with stop action' do
- given(:pipeline) { create(:ci_pipeline, project: project) }
- given(:build) { create(:ci_build, pipeline: pipeline) }
- given(:manual) { create(:ci_build, :manual, pipeline: pipeline, name: 'close_app') }
- given(:deployment) do
- create(:deployment, environment: environment, ref: merge_request.target_branch,
- sha: sha, deployable: build, on_stop: 'close_app')
- end
-
- background do
- wait_for_requests
- end
-
- scenario 'does show stop button' do
- expect(page).to have_button('Stop environment')
- end
-
- scenario 'does start build when stop button clicked' do
- accept_confirm { click_button('Stop environment') }
-
- expect(page).to have_content('close_app')
- end
-
- context 'for reporter' do
- given(:role) { :reporter }
-
- scenario 'does not show stop button' do
- expect(page).not_to have_button('Stop environment')
- end
- end
- end
- end
-end
diff --git a/spec/features/projects/merge_requests/list_spec.rb b/spec/features/projects/merge_requests/list_spec.rb
deleted file mode 100644
index b34b13db381..00000000000
--- a/spec/features/projects/merge_requests/list_spec.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-require 'spec_helper'
-
-feature 'Merge Requests List' do
- let(:user) { create(:user) }
- let(:project) { create(:project, :repository) }
-
- background do
- project.add_developer(user)
-
- sign_in(user)
- end
-
- scenario 'user does not see create new list button' do
- create(:merge_request, source_project: project)
-
- visit project_merge_requests_path(project)
-
- expect(page).not_to have_selector('.js-new-board-list')
- end
-
- it 'should show an empty state' do
- visit project_merge_requests_path(project)
-
- expect(page).to have_selector('.empty-state')
- end
-
- it 'empty state should have a create merge request button' do
- visit project_merge_requests_path(project)
-
- expect(page).to have_link 'New merge request', href: project_new_merge_request_path(project)
- end
-
- context 'if there are merge requests' do
- before do
- create(:merge_request, assignee: user, source_project: project)
-
- visit project_merge_requests_path(project)
- end
-
- it 'should not show an empty state' do
- expect(page).not_to have_selector('.empty-state')
- end
- end
-end
diff --git a/spec/support/shared_examples/features/creatable_merge_request_shared_examples.rb b/spec/support/shared_examples/features/creatable_merge_request_shared_examples.rb
new file mode 100644
index 00000000000..5b0b609f7f2
--- /dev/null
+++ b/spec/support/shared_examples/features/creatable_merge_request_shared_examples.rb
@@ -0,0 +1,99 @@
+RSpec.shared_examples 'a creatable merge request' do
+ include WaitForRequests
+
+ let(:user) { create(:user) }
+ let(:user2) { create(:user) }
+ let(:target_project) { create(:project, :public, :repository) }
+ let(:source_project) { target_project }
+ let!(:milestone) { create(:milestone, project: target_project) }
+ let!(:label) { create(:label, project: target_project) }
+ let!(:label2) { create(:label, project: target_project) }
+
+ before do
+ source_project.add_master(user)
+ target_project.add_master(user)
+ target_project.add_master(user2)
+
+ sign_in(user)
+ visit project_new_merge_request_path(
+ target_project,
+ merge_request: {
+ source_project_id: source_project.id,
+ target_project_id: target_project.id,
+ source_branch: 'fix',
+ target_branch: 'master'
+ })
+ end
+
+ it 'creates new merge request', :js do
+ click_button 'Assignee'
+ page.within '.dropdown-menu-user' do
+ click_link user2.name
+ end
+ expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user2.id.to_s)
+ page.within '.js-assignee-search' do
+ expect(page).to have_content user2.name
+ end
+
+ click_link 'Assign to me'
+ expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)
+ page.within '.js-assignee-search' do
+ expect(page).to have_content user.name
+ end
+
+ click_button 'Milestone'
+ page.within '.issue-milestone' do
+ click_link milestone.title
+ end
+ expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
+ page.within '.js-milestone-select' do
+ expect(page).to have_content milestone.title
+ end
+
+ click_button 'Labels'
+ page.within '.dropdown-menu-labels' do
+ click_link label.title
+ click_link label2.title
+ end
+ page.within '.js-label-select' do
+ expect(page).to have_content label.title
+ end
+ expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
+ expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
+
+ click_button 'Submit merge request'
+
+ page.within '.issuable-sidebar' do
+ page.within '.assignee' do
+ expect(page).to have_content user.name
+ end
+
+ page.within '.milestone' do
+ expect(page).to have_content milestone.title
+ end
+
+ page.within '.labels' do
+ expect(page).to have_content label.title
+ expect(page).to have_content label2.title
+ end
+ end
+ end
+
+ it 'updates the branches when selecting a new target project' do
+ target_project_member = target_project.owner
+ CreateBranchService.new(target_project, target_project_member)
+ .execute('a-brand-new-branch-to-test', 'master')
+ visit project_new_merge_request_path(source_project)
+
+ first('.js-target-project').click
+ find('.dropdown-target-project .dropdown-content a', text: target_project.full_path).click
+
+ wait_for_requests
+
+ first('.js-target-branch').click
+
+ within('.dropdown-target-branch .dropdown-content') do
+ expect(page).to have_content('a-brand-new-branch-to-test')
+ end
+ end
+end
diff --git a/spec/support/shared_examples/features/editable_merge_request_shared_examples.rb b/spec/support/shared_examples/features/editable_merge_request_shared_examples.rb
new file mode 100644
index 00000000000..645db41cddc
--- /dev/null
+++ b/spec/support/shared_examples/features/editable_merge_request_shared_examples.rb
@@ -0,0 +1,140 @@
+RSpec.shared_examples 'an editable merge request' do
+ let(:user) { create(:user) }
+ let(:user2) { create(:user) }
+ let!(:milestone) { create(:milestone, project: target_project) }
+ let!(:label) { create(:label, project: target_project) }
+ let!(:label2) { create(:label, project: target_project) }
+ let(:target_project) { create(:project, :public, :repository) }
+ let(:source_project) { target_project }
+ let(:merge_request) do
+ create(:merge_request,
+ source_project: source_project,
+ target_project: target_project,
+ source_branch: 'fix',
+ target_branch: 'master')
+ end
+
+ before do
+ source_project.add_master(user)
+ target_project.add_master(user)
+ target_project.add_master(user2)
+
+ sign_in(user)
+ visit edit_project_merge_request_path(target_project, merge_request)
+ end
+
+ it 'updates merge request', :js do
+ click_button 'Assignee'
+ page.within '.dropdown-menu-user' do
+ click_link user.name
+ end
+ expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)
+ page.within '.js-assignee-search' do
+ expect(page).to have_content user.name
+ end
+
+ click_button 'Milestone'
+ page.within '.issue-milestone' do
+ click_link milestone.title
+ end
+ expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
+ page.within '.js-milestone-select' do
+ expect(page).to have_content milestone.title
+ end
+
+ click_button 'Labels'
+ page.within '.dropdown-menu-labels' do
+ click_link label.title
+ click_link label2.title
+ end
+ expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
+ expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
+ page.within '.js-label-select' do
+ expect(page).to have_content label.title
+ end
+
+ click_button 'Save changes'
+
+ page.within '.issuable-sidebar' do
+ page.within '.assignee' do
+ expect(page).to have_content user.name
+ end
+
+ page.within '.milestone' do
+ expect(page).to have_content milestone.title
+ end
+
+ page.within '.labels' do
+ expect(page).to have_content label.title
+ expect(page).to have_content label2.title
+ end
+ end
+ end
+
+ it 'description has autocomplete', :js do
+ find('#merge_request_description').native.send_keys('')
+ fill_in 'merge_request_description', with: '@'
+
+ expect(page).to have_selector('.atwho-view')
+ end
+
+ it 'has class js-quick-submit in form' do
+ expect(page).to have_selector('.js-quick-submit')
+ end
+
+ it 'warns about version conflict' do
+ merge_request.update(title: "New title")
+
+ fill_in 'merge_request_title', with: 'bug 345'
+ fill_in 'merge_request_description', with: 'bug description'
+
+ click_button 'Save changes'
+
+ expect(page).to have_content 'Someone edited the merge request the same time you did'
+ end
+
+ it 'preserves description textarea height', :js do
+ long_description = %q(
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam ac ornare ligula, ut tempus arcu. Etiam ultricies accumsan dolor vitae faucibus. Donec at elit lacus. Mauris orci ante, aliquam quis lorem eget, convallis faucibus arcu. Aenean at pulvinar lacus. Ut viverra quam massa, molestie ornare tortor dignissim a. Suspendisse tristique pellentesque tellus, id lacinia metus elementum id. Nam tristique, arcu rhoncus faucibus viverra, lacus ipsum sagittis ligula, vitae convallis odio lacus a nibh. Ut tincidunt est purus, ac vestibulum augue maximus in. Suspendisse vel erat et mi ultricies semper. Pellentesque volutpat pellentesque consequat.
+
+ Cras congue nec ligula tristique viverra. Curabitur fringilla fringilla fringilla. Donec rhoncus dignissim orci ut accumsan. Ut rutrum urna a rhoncus varius. Maecenas blandit, mauris nec accumsan gravida, augue nibh finibus magna, sed maximus turpis libero nec neque. Suspendisse at semper est. Nunc imperdiet dapibus dui, varius sollicitudin erat luctus non. Sed pellentesque ligula eget posuere facilisis. Donec dictum commodo volutpat. Donec egestas dui ac magna sollicitudin bibendum. Vivamus purus neque, ullamcorper ac feugiat et, tempus sit amet metus. Praesent quis viverra neque. Sed bibendum viverra est, eu aliquam mi ornare vitae. Proin et dapibus ipsum. Nunc tortor diam, malesuada nec interdum vel, placerat quis justo. Ut viverra at erat eu laoreet.
+
+ Pellentesque commodo, diam sit amet dignissim condimentum, tortor justo pretium est, non venenatis metus eros ut nunc. Etiam ut neque eget sem dapibus aliquam. Curabitur vel elit lorem. Nulla nec enim elit. Sed ut ex id justo facilisis convallis at ac augue. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nullam cursus egestas turpis non tristique. Suspendisse in erat sem. Fusce libero elit, fermentum gravida mauris id, auctor iaculis felis. Nullam vulputate tempor laoreet.
+
+ Nam tempor et magna sed convallis. Fusce sit amet sollicitudin risus, a ullamcorper lacus. Morbi gravida quis sem eget porttitor. Donec eu egestas mauris, in elementum tortor. Sed eget ex mi. Mauris iaculis tortor ut est auctor, nec dignissim quam sagittis. Suspendisse vel metus non quam suscipit tincidunt. Cras molestie lacus non justo finibus sodales quis vitae erat. In a porttitor nisi, id sollicitudin urna. Ut at felis tellus. Suspendisse potenti.
+
+ Maecenas leo ligula, varius at neque vitae, ornare maximus justo. Nullam convallis luctus risus et vulputate. Duis suscipit faucibus iaculis. Etiam quis tortor faucibus, tristique tellus sit amet, sodales neque. Nulla dapibus nisi vel aliquet consequat. Etiam faucibus, metus eget condimentum iaculis, enim urna lobortis sem, id efficitur eros sapien nec nisi. Aenean ut finibus ex.
+ )
+
+ fill_in 'merge_request_description', with: long_description
+
+ height = get_textarea_height
+ find('.js-md-preview-button').click
+ find('.js-md-write-button').click
+ new_height = get_textarea_height
+
+ expect(height).to eq(new_height)
+ end
+
+ context 'when "Remove source branch" is set' do
+ before do
+ merge_request.update!(merge_params: { 'force_remove_source_branch' => '1' })
+ end
+
+ it 'allows to unselect "Remove source branch"', :js do
+ expect(merge_request.merge_params['force_remove_source_branch']).to be_truthy
+
+ visit edit_project_merge_request_path(target_project, merge_request)
+ uncheck 'Remove source branch when merge request is accepted'
+
+ click_button 'Save changes'
+
+ expect(page).to have_unchecked_field 'remove-source-branch-input'
+ expect(page).to have_content 'Remove source branch'
+ end
+ end
+end
+
+def get_textarea_height
+ page.evaluate_script('document.getElementById("merge_request_description").offsetHeight')
+end