summaryrefslogtreecommitdiff
path: root/spec/models/merge_request_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-14 00:09:07 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-14 00:09:07 +0000
commite144369009f3404072f7e0f969f7cded93195a01 (patch)
treed7a354e2c3c69a7ad65dc81aba8fe2ba59b0a26f /spec/models/merge_request_spec.rb
parentd466ee5042520ad078fe050cb078d81dc2ebe196 (diff)
downloadgitlab-ce-e144369009f3404072f7e0f969f7cded93195a01.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/merge_request_spec.rb')
-rw-r--r--spec/models/merge_request_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index 08348e3767a..36fd5d21e73 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -3576,4 +3576,44 @@ describe MergeRequest do
expect(merge_request.recent_visible_deployments.count).to eq(10)
end
end
+
+ describe '#diffable_merge_ref?' do
+ context 'diff_compare_with_head enabled' do
+ context 'merge request can be merged' do
+ context 'merge_to_ref is not calculated' do
+ it 'returns true' do
+ expect(subject.diffable_merge_ref?).to eq(false)
+ end
+ end
+
+ context 'merge_to_ref is calculated' do
+ before do
+ MergeRequests::MergeToRefService.new(subject.project, subject.author).execute(subject)
+ end
+
+ it 'returns true' do
+ expect(subject.diffable_merge_ref?).to eq(true)
+ end
+ end
+ end
+
+ context 'merge request cannot be merged' do
+ it 'returns false' do
+ subject.mark_as_unchecked!
+
+ expect(subject.diffable_merge_ref?).to eq(false)
+ end
+ end
+ end
+
+ context 'diff_compare_with_head disabled' do
+ before do
+ stub_feature_flags(diff_compare_with_head: { enabled: false, thing: subject.target_project })
+ end
+
+ it 'returns false' do
+ expect(subject.diffable_merge_ref?).to eq(false)
+ end
+ end
+ end
end