From d3d0e3dd5de9d00cbb6c8f2ec3c82bfdbb146ff3 Mon Sep 17 00:00:00 2001
From: Robert Speicher <rspeicher@gmail.com>
Date: Mon, 13 Jun 2016 17:43:29 -0400
Subject: [PATCH] Update `Gitlab.com?` to support staging

---
 lib/gitlab.rb           | 7 ++++++-
 spec/lib/gitlab_spec.rb | 6 ++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/gitlab.rb b/lib/gitlab.rb
index 37f4c34054f..c3064163e07 100644
--- a/lib/gitlab.rb
+++ b/lib/gitlab.rb
@@ -2,6 +2,11 @@ require_dependency 'gitlab/git'
 
 module Gitlab
   def self.com?
-    Gitlab.config.gitlab.url == 'https://gitlab.com'
+    # Check `staging?` as well to keep parity with gitlab.com
+    Gitlab.config.gitlab.url == 'https://gitlab.com' || staging?
+  end
+
+  def self.staging?
+    Gitlab.config.gitlab.url == 'https://staging.gitlab.com'
   end
 end
diff --git a/spec/lib/gitlab_spec.rb b/spec/lib/gitlab_spec.rb
index c59dfea5c55..c4c107c9eea 100644
--- a/spec/lib/gitlab_spec.rb
+++ b/spec/lib/gitlab_spec.rb
@@ -8,6 +8,12 @@ describe Gitlab, lib: true do
       expect(described_class.com?).to eq true
     end
 
+    it 'is true when on staging' do
+      stub_config_setting(url: 'https://staging.gitlab.com')
+
+      expect(described_class.com?).to eq true
+    end
+
     it 'is false when not on GitLab.com' do
       stub_config_setting(url: 'http://example.com')
 
-- 
GitLab