diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2016-11-23 17:13:27 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2016-11-23 17:13:27 +0300 |
commit | 8fcdfeaee23b87a1d7d8357e693ce7d9df97ab6a (patch) | |
tree | d3a48a79d3d60ef00a67fa0e141afab438b1fc19 /spec | |
parent | 4646d453b3211e29ec5afba2568766018caf32e0 (diff) | |
parent | f2a0c6f6bf768db8837283ad65fe6790b9105d26 (diff) |
Merge branch '24863-mrs-without-discussions-are-mergeable' into 'master'
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/24863
See merge request !7698
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/merge_request_spec.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 0b4277b1edd..58ccd056328 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -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 |