2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
require 'spec_helper'
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'Merge request > User sees merge button depending on unresolved threads', :js do
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project, :repository) }
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:user) { project.creator }
|
2017-08-17 22:00:37 +05:30
|
|
|
let!(:merge_request) { create(:merge_request_with_diff_notes, source_project: project, author: user) }
|
|
|
|
|
|
|
|
before do
|
2018-11-18 11:00:15 +05:30
|
|
|
project.add_maintainer(user)
|
2018-03-17 18:26:18 +05:30
|
|
|
sign_in(user)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
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)
|
2018-03-17 18:26:18 +05:30
|
|
|
visit project_merge_request_path(project, merge_request)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
context 'with unresolved threads' do
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'does not allow to merge' do
|
|
|
|
expect(page).not_to have_button 'Merge'
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(page).to have_content('Before this can be merged,')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
context 'with all threads resolved' do
|
2017-08-17 22:00:37 +05:30
|
|
|
before do
|
|
|
|
merge_request.discussions.each { |d| d.resolve!(user) }
|
2018-03-17 18:26:18 +05:30
|
|
|
visit project_merge_request_path(project, merge_request)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows MR to be merged' do
|
|
|
|
expect(page).to have_button 'Merge'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
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)
|
2018-03-17 18:26:18 +05:30
|
|
|
visit project_merge_request_path(project, merge_request)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
context 'with unresolved threads' do
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'does not allow to merge' do
|
|
|
|
expect(page).to have_button 'Merge'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
context 'with all threads resolved' do
|
2017-08-17 22:00:37 +05:30
|
|
|
before do
|
|
|
|
merge_request.discussions.each { |d| d.resolve!(user) }
|
2018-03-17 18:26:18 +05:30
|
|
|
visit project_merge_request_path(project, merge_request)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows MR to be merged' do
|
|
|
|
expect(page).to have_button 'Merge'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|