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