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