From 7cd8b14580c57a3dd7acfcba4cdd2b0da012772d Mon Sep 17 00:00:00 2001
From: Nick Thomas <nick@gitlab.com>
Date: Fri, 14 Jul 2017 02:30:47 +0100
Subject: [PATCH] Merge request approvals before merge should be nil if
 unavailable

---
 app/models/concerns/approvable.rb    | 2 +-
 spec/models/ee/merge_request_spec.rb | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/app/models/concerns/approvable.rb b/app/models/concerns/approvable.rb
index a458fdda93c..0cefa4277bf 100644
--- a/app/models/concerns/approvable.rb
+++ b/app/models/concerns/approvable.rb
@@ -23,7 +23,7 @@ module Approvable
   end
 
   def approvals_before_merge
-    return 0 unless project&.feature_available?(:merge_request_approvers)
+    return nil unless project&.feature_available?(:merge_request_approvers)
 
     super
   end
diff --git a/spec/models/ee/merge_request_spec.rb b/spec/models/ee/merge_request_spec.rb
index 9ff12c79532..965974159d2 100644
--- a/spec/models/ee/merge_request_spec.rb
+++ b/spec/models/ee/merge_request_spec.rb
@@ -136,10 +136,10 @@ describe MergeRequest, models: true do
 
   describe '#approvals_before_merge' do
     [
-      { license: true,  database: 5,  expected: 5 },
-      { license: true,  database: 0,  expected: 0 },
-      { license: false, database: 5,  expected: 0 },
-      { license: false, database: 0,  expected: 0 }
+      { license: true,  database: 5,   expected: 5 },
+      { license: true,  database: nil, expected: nil },
+      { license: false, database: 5,   expected: nil },
+      { license: false, database: nil, expected: nil }
     ].each do |spec|
       context spec.inspect do
         let(:spec) { spec }
-- 
2.30.9