2017-04-05 12:43:03 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-25 08:14:07 +00:00
|
|
|
feature 'Dashboard Merge Requests' do
|
|
|
|
include FilterItemSelectHelper
|
2017-07-14 13:36:37 +00:00
|
|
|
include SortingHelper
|
2017-09-29 08:04:50 +00:00
|
|
|
include ProjectForksHelper
|
2017-06-25 08:14:07 +00:00
|
|
|
|
2017-04-05 12:43:03 +00:00
|
|
|
let(:current_user) { create :user }
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project) }
|
2017-04-05 12:43:03 +00:00
|
|
|
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:public_project) { create(:project, :public, :repository) }
|
2017-09-29 08:04:50 +00:00
|
|
|
let(:forked_project) { fork_project(public_project, current_user, repository: true) }
|
2017-05-30 04:35:49 +00:00
|
|
|
|
2017-06-25 08:14:07 +00:00
|
|
|
before do
|
|
|
|
project.add_master(current_user)
|
|
|
|
sign_in(current_user)
|
2017-04-05 12:43:03 +00:00
|
|
|
end
|
|
|
|
|
2017-06-25 08:14:07 +00:00
|
|
|
context 'new merge request dropdown' do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project_with_disabled_merge_requests) { create(:project, :merge_requests_disabled) }
|
2017-06-25 08:14:07 +00:00
|
|
|
|
2017-06-14 18:18:56 +00:00
|
|
|
before do
|
2017-06-25 08:14:07 +00:00
|
|
|
project_with_disabled_merge_requests.add_master(current_user)
|
2017-06-14 18:18:56 +00:00
|
|
|
visit merge_requests_dashboard_path
|
|
|
|
end
|
2017-05-30 04:35:49 +00:00
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
it 'shows projects only with merge requests feature enabled', :js do
|
2017-06-17 06:08:27 +00:00
|
|
|
find('.new-project-item-select-button').click
|
2017-05-30 04:35:49 +00:00
|
|
|
|
|
|
|
page.within('.select2-results') do
|
|
|
|
expect(page).to have_content(project.name_with_namespace)
|
2017-06-25 08:14:07 +00:00
|
|
|
expect(page).not_to have_content(project_with_disabled_merge_requests.name_with_namespace)
|
2017-05-30 04:35:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-06-25 08:14:07 +00:00
|
|
|
context 'no merge requests exist' do
|
|
|
|
it 'shows an empty state' do
|
|
|
|
visit merge_requests_dashboard_path(assignee_id: current_user.id)
|
2017-04-05 12:43:03 +00:00
|
|
|
|
2017-06-25 08:14:07 +00:00
|
|
|
expect(page).to have_selector('.empty-state')
|
|
|
|
end
|
2017-04-05 12:43:03 +00:00
|
|
|
end
|
|
|
|
|
2017-06-25 08:14:07 +00:00
|
|
|
context 'merge requests exist' do
|
|
|
|
let!(:assigned_merge_request) do
|
2017-08-04 17:14:04 +00:00
|
|
|
create(:merge_request,
|
|
|
|
assignee: current_user,
|
|
|
|
source_project: project,
|
|
|
|
author: create(:user))
|
2017-06-25 08:14:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
let!(:assigned_merge_request_from_fork) do
|
|
|
|
create(:merge_request,
|
|
|
|
source_branch: 'markdown', assignee: current_user,
|
2017-08-04 17:14:04 +00:00
|
|
|
target_project: public_project, source_project: forked_project,
|
|
|
|
author: create(:user))
|
2017-06-25 08:14:07 +00:00
|
|
|
end
|
2017-04-05 12:43:03 +00:00
|
|
|
|
2017-06-25 08:14:07 +00:00
|
|
|
let!(:authored_merge_request) do
|
|
|
|
create(:merge_request,
|
2017-08-04 17:14:04 +00:00
|
|
|
source_branch: 'markdown',
|
|
|
|
source_project: project,
|
|
|
|
author: current_user)
|
2017-06-25 08:14:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
let!(:authored_merge_request_from_fork) do
|
|
|
|
create(:merge_request,
|
|
|
|
source_branch: 'feature_conflict',
|
|
|
|
author: current_user,
|
2017-08-04 17:14:04 +00:00
|
|
|
target_project: public_project, source_project: forked_project)
|
2017-06-25 08:14:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
let!(:other_merge_request) do
|
|
|
|
create(:merge_request,
|
|
|
|
source_branch: 'fix',
|
2017-08-04 17:14:04 +00:00
|
|
|
source_project: project,
|
|
|
|
author: create(:user))
|
2017-06-25 08:14:07 +00:00
|
|
|
end
|
|
|
|
|
2017-04-05 12:43:03 +00:00
|
|
|
before do
|
|
|
|
visit merge_requests_dashboard_path(assignee_id: current_user.id)
|
|
|
|
end
|
|
|
|
|
2017-06-25 08:14:07 +00:00
|
|
|
it 'shows assigned merge requests' do
|
|
|
|
expect(page).to have_content(assigned_merge_request.title)
|
|
|
|
expect(page).to have_content(assigned_merge_request_from_fork.title)
|
|
|
|
|
|
|
|
expect(page).not_to have_content(authored_merge_request.title)
|
|
|
|
expect(page).not_to have_content(authored_merge_request_from_fork.title)
|
|
|
|
expect(page).not_to have_content(other_merge_request.title)
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
it 'shows authored merge requests', :js do
|
2017-06-25 08:14:07 +00:00
|
|
|
filter_item_select('Any Assignee', '.js-assignee-search')
|
|
|
|
filter_item_select(current_user.to_reference, '.js-author-search')
|
|
|
|
|
|
|
|
expect(page).to have_content(authored_merge_request.title)
|
|
|
|
expect(page).to have_content(authored_merge_request_from_fork.title)
|
|
|
|
|
|
|
|
expect(page).not_to have_content(assigned_merge_request.title)
|
|
|
|
expect(page).not_to have_content(assigned_merge_request_from_fork.title)
|
|
|
|
expect(page).not_to have_content(other_merge_request.title)
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
it 'shows all merge requests', :js do
|
2017-06-25 08:14:07 +00:00
|
|
|
filter_item_select('Any Assignee', '.js-assignee-search')
|
|
|
|
filter_item_select('Any Author', '.js-author-search')
|
|
|
|
|
|
|
|
expect(page).to have_content(authored_merge_request.title)
|
|
|
|
expect(page).to have_content(authored_merge_request_from_fork.title)
|
|
|
|
expect(page).to have_content(assigned_merge_request.title)
|
|
|
|
expect(page).to have_content(assigned_merge_request_from_fork.title)
|
|
|
|
expect(page).to have_content(other_merge_request.title)
|
2017-04-05 12:43:03 +00:00
|
|
|
end
|
2017-07-14 13:36:37 +00:00
|
|
|
|
|
|
|
it 'shows sorted merge requests' do
|
2017-09-23 00:46:53 +00:00
|
|
|
sorting_by('Created date')
|
2017-04-05 12:43:03 +00:00
|
|
|
|
|
|
|
visit merge_requests_dashboard_path(assignee_id: current_user.id)
|
2017-07-14 13:36:37 +00:00
|
|
|
|
2017-09-23 00:46:53 +00:00
|
|
|
expect(find('.issues-filters')).to have_content('Created date')
|
2017-04-05 12:43:03 +00:00
|
|
|
end
|
|
|
|
|
2017-07-14 13:36:37 +00:00
|
|
|
it 'keeps sorting merge requests after visiting Projects MR page' do
|
2017-09-23 00:46:53 +00:00
|
|
|
sorting_by('Created date')
|
2017-07-14 13:36:37 +00:00
|
|
|
|
|
|
|
visit project_merge_requests_path(project)
|
|
|
|
|
2017-09-23 00:46:53 +00:00
|
|
|
expect(find('.issues-filters')).to have_content('Created date')
|
2017-04-05 12:43:03 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|