summaryrefslogtreecommitdiff
path: root/spec/features/merge_requests
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-08-30 17:18:01 +0200
committerRémy Coutable <remy@rymai.me>2018-08-30 17:18:01 +0200
commitd004c768417ef95a4aecb58c6c241ceed1a73d8f (patch)
tree7dafc633b9592911af9657d22e0298e912a56c77 /spec/features/merge_requests
parent418d35d97491af3921e8f5cca2734b0063c143a9 (diff)
downloadgitlab-ce-d004c768417ef95a4aecb58c6c241ceed1a73d8f.tar.gz
Reorganize issues and merge request feature specs in the same folder
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/features/merge_requests')
-rw-r--r--spec/features/merge_requests/user_sorts_merge_requests_spec.rb92
-rw-r--r--spec/features/merge_requests/user_views_all_merge_requests_spec.rb15
-rw-r--r--spec/features/merge_requests/user_views_closed_merge_requests_spec.rb15
-rw-r--r--spec/features/merge_requests/user_views_merged_merge_requests_spec.rb15
-rw-r--r--spec/features/merge_requests/user_views_open_merge_requests_spec.rb127
5 files changed, 264 insertions, 0 deletions
diff --git a/spec/features/merge_requests/user_sorts_merge_requests_spec.rb b/spec/features/merge_requests/user_sorts_merge_requests_spec.rb
new file mode 100644
index 00000000000..82cfe600d52
--- /dev/null
+++ b/spec/features/merge_requests/user_sorts_merge_requests_spec.rb
@@ -0,0 +1,92 @@
+require 'spec_helper'
+
+describe 'User sorts merge requests' do
+ include CookieHelper
+
+ let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
+ let!(:merge_request2) do
+ create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: 'merge-test')
+ end
+ set(:user) { create(:user) }
+ set(:group) { create(:group) }
+ set(:group_member) { create(:group_member, :maintainer, user: user, group: group) }
+ set(:project) { create(:project, :public, group: group) }
+
+ before do
+ sign_in(user)
+
+ visit(project_merge_requests_path(project))
+ end
+
+ it 'keeps the sort option' do
+ find('button.dropdown-toggle').click
+
+ page.within('.content ul.dropdown-menu.dropdown-menu-right li') do
+ click_link('Milestone')
+ end
+
+ visit(merge_requests_dashboard_path(assignee_id: user.id))
+
+ expect(find('.issues-filters a.is-active')).to have_content('Milestone')
+
+ visit(project_merge_requests_path(project))
+
+ expect(find('.issues-filters a.is-active')).to have_content('Milestone')
+
+ visit(merge_requests_group_path(group))
+
+ expect(find('.issues-filters a.is-active')).to have_content('Milestone')
+ end
+
+ it 'fallbacks to issuable_sort cookie key when remembering the sorting option' do
+ set_cookie('issuable_sort', 'milestone')
+
+ visit(merge_requests_dashboard_path(assignee_id: user.id))
+
+ expect(find('.issues-filters a.is-active')).to have_content('Milestone')
+ end
+
+ it 'separates remember sorting with issues' do
+ create(:issue, project: project)
+
+ find('button.dropdown-toggle').click
+
+ page.within('.content ul.dropdown-menu.dropdown-menu-right li') do
+ click_link('Milestone')
+ end
+
+ visit(project_issues_path(project))
+
+ expect(find('.issues-filters a.is-active')).not_to have_content('Milestone')
+ end
+
+ context 'when merge requests have awards' do
+ before do
+ create_list(:award_emoji, 2, awardable: merge_request)
+ create(:award_emoji, :downvote, awardable: merge_request)
+
+ create(:award_emoji, awardable: merge_request2)
+ create_list(:award_emoji, 2, :downvote, awardable: merge_request2)
+ end
+
+ it 'sorts by popularity' do
+ find('button.dropdown-toggle').click
+
+ page.within('.content ul.dropdown-menu.dropdown-menu-right li') do
+ click_link('Popularity')
+ end
+
+ page.within('.mr-list') do
+ page.within('li.merge-request:nth-child(1)') do
+ expect(page).to have_content(merge_request.title)
+ expect(page).to have_content('2 1')
+ end
+
+ page.within('li.merge-request:nth-child(2)') do
+ expect(page).to have_content(merge_request2.title)
+ expect(page).to have_content('1 2')
+ end
+ end
+ end
+ end
+end
diff --git a/spec/features/merge_requests/user_views_all_merge_requests_spec.rb b/spec/features/merge_requests/user_views_all_merge_requests_spec.rb
new file mode 100644
index 00000000000..6c695bd7aa9
--- /dev/null
+++ b/spec/features/merge_requests/user_views_all_merge_requests_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe 'User views all merge requests' do
+ let!(:closed_merge_request) { create(:closed_merge_request, source_project: project, target_project: project) }
+ let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
+ let(:project) { create(:project, :public) }
+
+ before do
+ visit(project_merge_requests_path(project, state: :all))
+ end
+
+ it 'shows all merge requests' do
+ expect(page).to have_content(merge_request.title).and have_content(closed_merge_request.title)
+ end
+end
diff --git a/spec/features/merge_requests/user_views_closed_merge_requests_spec.rb b/spec/features/merge_requests/user_views_closed_merge_requests_spec.rb
new file mode 100644
index 00000000000..853809fe87a
--- /dev/null
+++ b/spec/features/merge_requests/user_views_closed_merge_requests_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe 'User views closed merge requests' do
+ let!(:closed_merge_request) { create(:closed_merge_request, source_project: project, target_project: project) }
+ let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
+ let(:project) { create(:project, :public) }
+
+ before do
+ visit(project_merge_requests_path(project, state: :closed))
+ end
+
+ it 'shows closed merge requests' do
+ expect(page).to have_content(closed_merge_request.title).and have_no_content(merge_request.title)
+ end
+end
diff --git a/spec/features/merge_requests/user_views_merged_merge_requests_spec.rb b/spec/features/merge_requests/user_views_merged_merge_requests_spec.rb
new file mode 100644
index 00000000000..eb012694f1e
--- /dev/null
+++ b/spec/features/merge_requests/user_views_merged_merge_requests_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe 'User views merged merge requests' do
+ let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
+ let!(:merged_merge_request) { create(:merged_merge_request, source_project: project, target_project: project) }
+ let(:project) { create(:project, :public) }
+
+ before do
+ visit(project_merge_requests_path(project, state: :merged))
+ end
+
+ it 'shows merged merge requests' do
+ expect(page).to have_content(merged_merge_request.title).and have_no_content(merge_request.title)
+ end
+end
diff --git a/spec/features/merge_requests/user_views_open_merge_requests_spec.rb b/spec/features/merge_requests/user_views_open_merge_requests_spec.rb
new file mode 100644
index 00000000000..115e548b691
--- /dev/null
+++ b/spec/features/merge_requests/user_views_open_merge_requests_spec.rb
@@ -0,0 +1,127 @@
+require 'spec_helper'
+
+describe 'User views open merge requests' do
+ set(:user) { create(:user) }
+
+ shared_examples_for 'shows merge requests' do
+ it 'shows merge requests' do
+ expect(page).to have_content(project.name).and have_content(merge_request.source_project.name)
+ end
+ end
+
+ context 'when project is public' do
+ set(:project) { create(:project, :public, :repository) }
+
+ context 'when not signed in' do
+ context "when the target branch is the project's default branch" do
+ let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
+ let!(:closed_merge_request) { create(:closed_merge_request, source_project: project, target_project: project) }
+
+ before do
+ visit(project_merge_requests_path(project))
+ end
+
+ include_examples 'shows merge requests'
+
+ it 'shows open merge requests' do
+ expect(page).to have_content(merge_request.title).and have_no_content(closed_merge_request.title)
+ end
+
+ it 'does not show target branch name' do
+ expect(page).to have_content(merge_request.title)
+ expect(find('.issuable-info')).not_to have_content(project.default_branch)
+ end
+ end
+
+ context "when the target branch is different from the project's default branch" do
+ let!(:merge_request) do
+ create(:merge_request,
+ source_project: project,
+ target_project: project,
+ source_branch: 'fix',
+ target_branch: 'feature_conflict')
+ end
+
+ before do
+ visit(project_merge_requests_path(project))
+ end
+
+ it 'shows target branch name' do
+ expect(page).to have_content(merge_request.target_branch)
+ end
+ end
+
+ context 'when a merge request has pipelines' do
+ let!(:build) { create :ci_build, pipeline: pipeline }
+
+ let(:merge_request) do
+ create(:merge_request_with_diffs,
+ source_project: project,
+ target_project: project,
+ source_branch: 'merge-test')
+ end
+
+ let(:pipeline) do
+ create(:ci_pipeline,
+ project: project,
+ sha: merge_request.diff_head_sha,
+ ref: merge_request.source_branch,
+ head_pipeline_of: merge_request)
+ end
+
+ before do
+ project.enable_ci
+
+ visit(project_merge_requests_path(project))
+ end
+
+ it 'shows pipeline status' do
+ page.within('.mr-list') do
+ expect(page).to have_link('Pipeline: pending')
+ end
+ end
+ end
+ end
+
+ context 'when signed in' do
+ let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
+
+ before do
+ project.add_developer(user)
+ sign_in(user)
+
+ visit(project_merge_requests_path(project))
+ end
+
+ include_examples 'shows merge requests'
+
+ it 'shows the new merge request button' do
+ expect(page).to have_link('New merge request')
+ end
+
+ context 'when the project is archived' do
+ let(:project) { create(:project, :public, :repository, :archived) }
+
+ it 'hides the new merge request button' do
+ expect(page).not_to have_link('New merge request')
+ end
+ end
+ end
+ end
+
+ context 'when project is internal' do
+ let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
+ set(:project) { create(:project, :internal, :repository) }
+
+ context 'when signed in' do
+ before do
+ project.add_developer(user)
+ sign_in(user)
+
+ visit(project_merge_requests_path(project))
+ end
+
+ include_examples 'shows merge requests'
+ end
+ end
+end