From be9262dd951e056e832ec51f8b74a8cb7ce866b4 Mon Sep 17 00:00:00 2001
From: Douglas Barbosa Alexandre <dbalexandre@gmail.com>
Date: Mon, 11 Jul 2016 18:53:39 -0300
Subject: [PATCH] Checks if rate limit is enabled instead of stubbing response

---
 lib/gitlab/github_import/client.rb | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/gitlab/github_import/client.rb b/lib/gitlab/github_import/client.rb
index f57f5b74706..f2e220fcb3e 100644
--- a/lib/gitlab/github_import/client.rb
+++ b/lib/gitlab/github_import/client.rb
@@ -82,11 +82,15 @@ module Gitlab
       # disabled. In this case we just want to return gracefully
       # instead of spitting out an error.
       rescue Octokit::NotFound
-        OpenStruct.new(remaining: GITHUB_SAFE_REMAINING_REQUESTS + 1)
+        nil
+      end
+
+      def has_rate_limit?
+        rate_limit.present?
       end
 
       def rate_limit_exceed?
-        rate_limit.remaining <= GITHUB_SAFE_REMAINING_REQUESTS
+        has_rate_limit? && rate_limit.remaining <= GITHUB_SAFE_REMAINING_REQUESTS
       end
 
       def rate_limit_sleep_time
-- 
GitLab