Commit 8fcdfeae authored by Sean McGivern's avatar Sean McGivern

Merge branch '24863-mrs-without-discussions-are-mergeable' into 'master'

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/24863

See merge request !7698
parents 4646d453 f2a0c6f6
......@@ -494,10 +494,14 @@ class MergeRequest < ActiveRecord::Base
discussions_resolvable? && diff_discussions.none?(&:to_be_resolved?)
end
def discussions_to_be_resolved?
discussions_resolvable? && !discussions_resolved?
end
def mergeable_discussions_state?
return true unless project.only_allow_merge_if_all_discussions_are_resolved?
discussions_resolved?
!discussions_to_be_resolved?
end
def hook_attrs
......
---
title: Correctly determine mergeability of MR with no discussions
merge_request:
author:
......@@ -937,6 +937,16 @@ describe MergeRequest, models: true do
expect(merge_request.mergeable_discussions_state?).to be_falsey
end
end
context 'with no discussions' do
before do
merge_request.notes.destroy_all
end
it 'returns true' do
expect(merge_request.mergeable_discussions_state?).to be_truthy
end
end
end
context 'when project.only_allow_merge_if_all_discussions_are_resolved == false' do
......@@ -1198,6 +1208,50 @@ describe MergeRequest, models: true do
end
end
end
describe "#discussions_to_be_resolved?" do
context "when discussions are not resolvable" do
before do
allow(subject).to receive(:discussions_resolvable?).and_return(false)
end
it "returns false" do
expect(subject.discussions_to_be_resolved?).to be false
end
end
context "when discussions are resolvable" do
before do
allow(subject).to receive(:discussions_resolvable?).and_return(true)
allow(first_discussion).to receive(:resolvable?).and_return(true)
allow(second_discussion).to receive(:resolvable?).and_return(false)
allow(third_discussion).to receive(:resolvable?).and_return(true)
end
context "when all resolvable discussions are resolved" do
before do
allow(first_discussion).to receive(:resolved?).and_return(true)
allow(third_discussion).to receive(:resolved?).and_return(true)
end
it "returns false" do
expect(subject.discussions_to_be_resolved?).to be false
end
end
context "when some resolvable discussions are not resolved" do
before do
allow(first_discussion).to receive(:resolved?).and_return(true)
allow(third_discussion).to receive(:resolved?).and_return(false)
end
it "returns true" do
expect(subject.discussions_to_be_resolved?).to be true
end
end
end
end
end
describe '#conflicts_can_be_resolved_in_ui?' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment