2016-09-16 11:02:42 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
feature 'Check if mergeable with unresolved discussions', :js do
|
2016-10-26 17:19:17 +00:00
|
|
|
let(:user) { create(:user) }
|
2017-07-26 21:52:10 +00:00
|
|
|
let(:project) { create(:project, :repository) }
|
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
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in user
|
2016-09-16 11:02:42 +00:00
|
|
|
project.team << [user, :master]
|
|
|
|
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)
|
2016-09-16 11:02:42 +00:00
|
|
|
end
|
|
|
|
|
2016-10-26 17:19:17 +00:00
|
|
|
context 'with unresolved discussions' do
|
|
|
|
it 'does not allow to merge' do
|
|
|
|
visit_merge_request(merge_request)
|
2016-09-16 11:02:42 +00:00
|
|
|
|
2017-05-09 04:15:34 +00:00
|
|
|
expect(page).not_to have_button 'Merge'
|
|
|
|
expect(page).to have_content('There are unresolved discussions.')
|
2016-10-26 17:19:17 +00:00
|
|
|
end
|
|
|
|
end
|
2016-09-16 11:02:42 +00:00
|
|
|
|
2016-10-26 17:19:17 +00:00
|
|
|
context 'with all discussions resolved' do
|
2016-09-16 11:02:42 +00:00
|
|
|
before do
|
|
|
|
merge_request.discussions.each { |d| d.resolve!(user) }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows MR to be merged' do
|
|
|
|
visit_merge_request(merge_request)
|
|
|
|
|
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)
|
|
|
|
end
|
2016-09-16 11:02:42 +00:00
|
|
|
|
2016-10-26 17:19:17 +00:00
|
|
|
context 'with unresolved discussions' do
|
2016-09-16 11:02:42 +00:00
|
|
|
it 'does not allow to merge' do
|
|
|
|
visit_merge_request(merge_request)
|
|
|
|
|
2017-05-09 04:15:34 +00:00
|
|
|
expect(page).to have_button 'Merge'
|
2016-10-26 17:19:17 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with all discussions resolved' do
|
|
|
|
before do
|
|
|
|
merge_request.discussions.each { |d| d.resolve!(user) }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows MR to be merged' do
|
|
|
|
visit_merge_request(merge_request)
|
|
|
|
|
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
|
|
|
|
|
|
|
|
def visit_merge_request(merge_request)
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_request_path(merge_request.project, merge_request)
|
2016-09-16 11:02:42 +00:00
|
|
|
end
|
|
|
|
end
|