2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 07:56:52 +00:00
|
|
|
require 'spec_helper'
|
2016-09-07 10:54:39 +00:00
|
|
|
|
2020-06-16 18:09:01 +00:00
|
|
|
RSpec.describe 'Merge requests > User mass updates', :js do
|
2017-08-01 18:03:07 +00:00
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:user) { project.creator }
|
2016-09-07 10:54:39 +00:00
|
|
|
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
|
|
|
|
|
|
|
|
before do
|
2022-02-04 12:17:40 +00:00
|
|
|
stub_feature_flags(mr_attention_requests: false)
|
|
|
|
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2016-09-07 10:54:39 +00:00
|
|
|
end
|
|
|
|
|
2017-08-01 18:03:07 +00:00
|
|
|
context 'status' do
|
2016-09-08 12:33:53 +00:00
|
|
|
describe 'close merge request' do
|
|
|
|
before do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project)
|
2016-09-08 12:33:53 +00:00
|
|
|
end
|
2016-09-07 10:54:39 +00:00
|
|
|
|
2021-06-18 15:10:16 +00:00
|
|
|
it 'closes merge request', :js do
|
2016-09-08 12:33:53 +00:00
|
|
|
change_status('Closed')
|
|
|
|
|
|
|
|
expect(page).to have_selector('.merge-request', count: 0)
|
|
|
|
end
|
2016-09-07 10:54:39 +00:00
|
|
|
end
|
|
|
|
|
2016-09-08 12:33:53 +00:00
|
|
|
describe 'reopen merge request' do
|
|
|
|
before do
|
|
|
|
merge_request.close
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project, state: 'closed')
|
2016-09-08 12:33:53 +00:00
|
|
|
end
|
|
|
|
|
2021-06-18 15:10:16 +00:00
|
|
|
it 'reopens merge request', :js do
|
2016-09-08 12:33:53 +00:00
|
|
|
change_status('Open')
|
2016-09-07 10:54:39 +00:00
|
|
|
|
2016-09-08 12:33:53 +00:00
|
|
|
expect(page).to have_selector('.merge-request', count: 0)
|
|
|
|
end
|
2016-09-07 10:54:39 +00:00
|
|
|
end
|
2020-07-29 18:09:50 +00:00
|
|
|
|
|
|
|
it 'does not exist in merged state' do
|
|
|
|
merge_request.close
|
|
|
|
visit project_merge_requests_path(project, state: 'merged')
|
|
|
|
|
|
|
|
click_button 'Edit merge requests'
|
|
|
|
|
2021-05-19 03:10:31 +00:00
|
|
|
expect(page).not_to have_button 'Select status'
|
2020-07-29 18:09:50 +00:00
|
|
|
end
|
2016-09-07 10:54:39 +00:00
|
|
|
end
|
|
|
|
|
2017-08-01 18:03:07 +00:00
|
|
|
context 'assignee' do
|
2016-09-08 12:33:53 +00:00
|
|
|
describe 'set assignee' do
|
2016-09-08 08:46:04 +00:00
|
|
|
before do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project)
|
2016-09-08 08:46:04 +00:00
|
|
|
end
|
2016-09-07 10:54:39 +00:00
|
|
|
|
2017-08-01 18:03:07 +00:00
|
|
|
it 'updates merge request with assignee' do
|
2016-09-08 08:46:04 +00:00
|
|
|
change_assignee(user.name)
|
2016-09-07 10:54:39 +00:00
|
|
|
|
2021-05-19 03:10:31 +00:00
|
|
|
expect(find('.merge-request')).to have_link "Assigned to #{user.name}"
|
2016-09-07 10:54:39 +00:00
|
|
|
end
|
2022-02-04 12:17:40 +00:00
|
|
|
|
|
|
|
describe 'with attention requests feature flag on' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(mr_attention_requests: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates merge request with assignee' do
|
|
|
|
change_assignee(user.name)
|
|
|
|
|
|
|
|
expect(find('.issuable-meta a.author-link')[:title]).to eq "Attention requested from assignee #{user.name}, go to their profile."
|
|
|
|
end
|
|
|
|
end
|
2016-09-07 10:54:39 +00:00
|
|
|
end
|
|
|
|
|
2016-09-08 12:33:53 +00:00
|
|
|
describe 'remove assignee' do
|
2016-09-08 08:46:04 +00:00
|
|
|
before do
|
2019-04-07 18:35:16 +00:00
|
|
|
merge_request.assignees = [user]
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project)
|
2016-09-08 08:46:04 +00:00
|
|
|
end
|
2016-09-07 10:54:39 +00:00
|
|
|
|
2017-08-01 18:03:07 +00:00
|
|
|
it 'removes assignee from the merge request' do
|
2016-09-08 08:46:04 +00:00
|
|
|
change_assignee('Unassigned')
|
2016-09-08 12:33:53 +00:00
|
|
|
|
2021-05-19 03:10:31 +00:00
|
|
|
expect(find('.merge-request')).not_to have_link "Assigned to #{user.name}"
|
2016-09-08 08:46:04 +00:00
|
|
|
end
|
2016-09-07 10:54:39 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-01 18:03:07 +00:00
|
|
|
context 'milestone' do
|
2019-01-16 12:09:29 +00:00
|
|
|
let(:milestone) { create(:milestone, project: project) }
|
2016-09-07 10:54:39 +00:00
|
|
|
|
2016-09-08 12:33:53 +00:00
|
|
|
describe 'set milestone' do
|
2016-09-08 08:46:04 +00:00
|
|
|
before do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project)
|
2016-09-08 08:46:04 +00:00
|
|
|
end
|
2016-09-07 10:54:39 +00:00
|
|
|
|
2017-08-01 18:03:07 +00:00
|
|
|
it 'updates merge request with milestone' do
|
2016-09-08 08:46:04 +00:00
|
|
|
change_milestone(milestone.title)
|
2016-09-08 12:33:53 +00:00
|
|
|
|
2016-09-08 08:46:04 +00:00
|
|
|
expect(find('.merge-request')).to have_content milestone.title
|
|
|
|
end
|
2016-09-07 10:54:39 +00:00
|
|
|
end
|
|
|
|
|
2016-09-08 12:33:53 +00:00
|
|
|
describe 'unset milestone' do
|
2016-09-08 08:46:04 +00:00
|
|
|
before do
|
|
|
|
merge_request.milestone = milestone
|
2020-08-10 18:09:54 +00:00
|
|
|
merge_request.save!
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project)
|
2016-09-08 08:46:04 +00:00
|
|
|
end
|
2016-09-07 10:54:39 +00:00
|
|
|
|
2017-08-01 18:03:07 +00:00
|
|
|
it 'removes milestone from the merge request' do
|
2020-05-12 21:08:14 +00:00
|
|
|
change_milestone("No milestone")
|
2016-09-08 12:33:53 +00:00
|
|
|
|
2016-09-08 08:46:04 +00:00
|
|
|
expect(find('.merge-request')).not_to have_content milestone.title
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-09-07 10:54:39 +00:00
|
|
|
|
2016-09-08 08:46:04 +00:00
|
|
|
def change_status(text)
|
2017-08-15 08:07:41 +00:00
|
|
|
click_button 'Edit merge requests'
|
2021-05-19 03:10:31 +00:00
|
|
|
check 'Select all'
|
|
|
|
click_button 'Select status'
|
2021-06-18 15:10:16 +00:00
|
|
|
click_button text
|
2016-09-08 08:46:04 +00:00
|
|
|
click_update_merge_requests_button
|
|
|
|
end
|
2016-09-07 10:54:39 +00:00
|
|
|
|
2016-09-08 08:46:04 +00:00
|
|
|
def change_assignee(text)
|
2017-08-15 08:07:41 +00:00
|
|
|
click_button 'Edit merge requests'
|
2021-05-19 03:10:31 +00:00
|
|
|
check 'Select all'
|
|
|
|
within 'aside[aria-label="Bulk update"]' do
|
|
|
|
click_button 'Select assignee'
|
|
|
|
wait_for_requests
|
2016-09-08 08:46:04 +00:00
|
|
|
click_link text
|
2016-09-07 10:54:39 +00:00
|
|
|
end
|
2016-09-08 08:46:04 +00:00
|
|
|
click_update_merge_requests_button
|
2016-09-07 10:54:39 +00:00
|
|
|
end
|
|
|
|
|
2016-09-08 08:46:04 +00:00
|
|
|
def change_milestone(text)
|
2017-08-15 08:07:41 +00:00
|
|
|
click_button 'Edit merge requests'
|
2021-05-19 03:10:31 +00:00
|
|
|
check 'Select all'
|
|
|
|
click_button 'Select milestone'
|
|
|
|
click_link text
|
2016-09-08 08:46:04 +00:00
|
|
|
click_update_merge_requests_button
|
2016-09-07 10:54:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def click_update_merge_requests_button
|
2021-05-19 03:10:31 +00:00
|
|
|
click_button 'Update all'
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2016-09-07 10:54:39 +00:00
|
|
|
end
|
|
|
|
end
|