Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/zentao/client.rb')
-rw-r--r--lib/gitlab/zentao/client.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/gitlab/zentao/client.rb b/lib/gitlab/zentao/client.rb
index bdfa4b3a308..8acfb4913f3 100644
--- a/lib/gitlab/zentao/client.rb
+++ b/lib/gitlab/zentao/client.rb
@@ -15,10 +15,8 @@ module Gitlab
end
def ping
- response = fetch_product(zentao_product_xid)
-
- active = response.fetch('deleted') == '0' rescue false
-
+ response = fetch_product(zentao_product_xid) rescue {}
+ active = response['deleted'] == '0'
if active
{ success: true }
else
@@ -31,25 +29,30 @@ module Gitlab
end
def fetch_issues(params = {})
- get("products/#{zentao_product_xid}/issues",
- params.reverse_merge(page: 1, limit: 20))
+ get("products/#{zentao_product_xid}/issues", params)
end
def fetch_issue(issue_id)
+ raise Gitlab::Zentao::Client::Error, 'invalid issue id' unless issue_id_pattern.match(issue_id)
+
get("issues/#{issue_id}")
end
private
+ def issue_id_pattern
+ /\A\S+-\d+\z/
+ end
+
def get(path, params = {})
options = { headers: headers, query: params }
response = Gitlab::HTTP.get(url(path), options)
- return {} unless response.success?
+ raise Gitlab::Zentao::Client::Error, 'request error' unless response.success?
Gitlab::Json.parse(response.body)
rescue JSON::ParserError
- {}
+ raise Gitlab::Zentao::Client::Error, 'invalid response format'
end
def url(path)