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-16 11:02:42 +00:00
|
|
|
|
2020-06-16 18:09:01 +00:00
|
|
|
RSpec.describe 'Merge request > User sees merge button depending on unresolved threads', :js do
|
2017-07-26 21:52:10 +00:00
|
|
|
let(:project) { create(:project, :repository) }
|
2017-08-01 18:03:07 +00:00
|
|
|
let(:user) { project.creator }
|
2016-10-26 17:19:17 +00:00
|
|
|
let!(:merge_request) { create(:merge_request_with_diff_notes, source_project: project, author: user) }
|
2016-09-16 11:02:42 +00:00
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-08-01 18:03:07 +00:00
|
|
|
sign_in(user)
|
2016-09-16 11:02:42 +00:00
|
|
|
end
|
|
|
|
|
2016-10-26 17:19:17 +00:00
|
|
|
context 'when project.only_allow_merge_if_all_discussions_are_resolved == true' do
|
|
|
|
before do
|
|
|
|
project.update_column(:only_allow_merge_if_all_discussions_are_resolved, true)
|
2017-08-01 18:03:07 +00:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2016-09-16 11:02:42 +00:00
|
|
|
end
|
|
|
|
|
2019-06-14 09:18:03 +00:00
|
|
|
context 'with unresolved threads' do
|
2016-10-26 17:19:17 +00:00
|
|
|
it 'does not allow to merge' do
|
2017-05-09 04:15:34 +00:00
|
|
|
expect(page).not_to have_button 'Merge'
|
2021-05-06 12:10:38 +00:00
|
|
|
expect(page).to have_content('all threads must be resolved')
|
2016-10-26 17:19:17 +00:00
|
|
|
end
|
|
|
|
end
|
2016-09-16 11:02:42 +00:00
|
|
|
|
2019-06-14 09:18:03 +00:00
|
|
|
context 'with all threads resolved' do
|
2016-09-16 11:02:42 +00:00
|
|
|
before do
|
|
|
|
merge_request.discussions.each { |d| d.resolve!(user) }
|
2017-08-01 18:03:07 +00:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2016-09-16 11:02:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows MR to be merged' do
|
2017-05-09 04:15:34 +00:00
|
|
|
expect(page).to have_button 'Merge'
|
2016-09-16 11:02:42 +00:00
|
|
|
end
|
|
|
|
end
|
2016-10-26 17:19:17 +00:00
|
|
|
end
|
2016-09-16 11:02:42 +00:00
|
|
|
|
2016-10-26 17:19:17 +00:00
|
|
|
context 'when project.only_allow_merge_if_all_discussions_are_resolved == false' do
|
|
|
|
before do
|
|
|
|
project.update_column(:only_allow_merge_if_all_discussions_are_resolved, false)
|
2017-08-01 18:03:07 +00:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2016-10-26 17:19:17 +00:00
|
|
|
end
|
2016-09-16 11:02:42 +00:00
|
|
|
|
2019-06-14 09:18:03 +00:00
|
|
|
context 'with unresolved threads' do
|
2016-09-16 11:02:42 +00:00
|
|
|
it 'does not allow to merge' do
|
2017-05-09 04:15:34 +00:00
|
|
|
expect(page).to have_button 'Merge'
|
2016-10-26 17:19:17 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-14 09:18:03 +00:00
|
|
|
context 'with all threads resolved' do
|
2016-10-26 17:19:17 +00:00
|
|
|
before do
|
|
|
|
merge_request.discussions.each { |d| d.resolve!(user) }
|
2017-08-01 18:03:07 +00:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2016-10-26 17:19:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows MR to be merged' do
|
2017-05-09 04:15:34 +00:00
|
|
|
expect(page).to have_button 'Merge'
|
2016-09-16 11:02:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|