2016-09-07 10:54:39 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-08-01 18:03:07 +00:00
|
|
|
describe 'Merge requests > User mass updates', :js do
|
|
|
|
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
|
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
|
|
|
|
2016-09-08 12:33:53 +00:00
|
|
|
it 'closes merge request' do
|
|
|
|
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
|
|
|
|
|
|
|
|
it 'reopens merge request' do
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2016-09-08 08:46:04 +00:00
|
|
|
page.within('.merge-request .controls') do
|
2018-07-23 15:03:40 +00:00
|
|
|
expect(find('.author-link')["title"]).to have_content(user.name)
|
2016-09-08 08:46:04 +00:00
|
|
|
end
|
2016-09-07 10:54:39 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-09-08 12:33:53 +00:00
|
|
|
describe 'remove assignee' do
|
2016-09-08 08:46:04 +00:00
|
|
|
before do
|
|
|
|
merge_request.assignee = user
|
|
|
|
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 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
|
|
|
|
2018-07-23 20:27:37 +00:00
|
|
|
expect(find('.merge-request .controls')).not_to have_css('.author-link')
|
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
|
2016-09-07 10:54:39 +00:00
|
|
|
let(:milestone) { create(:milestone, project: project) }
|
|
|
|
|
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
|
|
|
|
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
|
2016-09-08 08:46:04 +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'
|
2017-05-15 22:12:43 +00:00
|
|
|
find('#check-all-issues').click
|
2016-09-08 08:46:04 +00:00
|
|
|
find('.js-issue-status').click
|
|
|
|
find('.dropdown-menu-status a', text: text).click
|
|
|
|
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'
|
2017-05-15 22:12:43 +00:00
|
|
|
find('#check-all-issues').click
|
2016-09-08 08:46:04 +00:00
|
|
|
find('.js-update-assignee').click
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2016-09-07 10:54:39 +00:00
|
|
|
|
2016-09-08 08:46:04 +00:00
|
|
|
page.within '.dropdown-menu-user' do
|
|
|
|
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'
|
2017-05-15 22:12:43 +00:00
|
|
|
find('#check-all-issues').click
|
|
|
|
find('.issues-bulk-update .js-milestone-select').click
|
2016-09-08 08:46:04 +00:00
|
|
|
find('.dropdown-menu-milestone a', text: text).click
|
|
|
|
click_update_merge_requests_button
|
2016-09-07 10:54:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def click_update_merge_requests_button
|
2017-09-27 18:13:07 +00:00
|
|
|
find('.update-selected-issues').click
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2016-09-07 10:54:39 +00:00
|
|
|
end
|
|
|
|
end
|