Commit c36e5998 authored by Baodong's avatar Baodong Committed by Mayra Cabrera

Add raise message to ZenTao client

parent aaa154be
......@@ -33,7 +33,7 @@ module Gitlab
end
def fetch_issue(issue_id)
raise Gitlab::Zentao::Client::Error unless issue_id_pattern.match(issue_id)
raise Gitlab::Zentao::Client::Error, 'invalid issue id' unless issue_id_pattern.match(issue_id)
get("issues/#{issue_id}")
end
......@@ -48,11 +48,11 @@ module Gitlab
options = { headers: headers, query: params }
response = Gitlab::HTTP.get(url(path), options)
raise Gitlab::Zentao::Client::Error 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
raise Gitlab::Zentao::Client::Error, 'invalid response format'
end
def url(path)
......
......@@ -63,7 +63,7 @@ RSpec.describe Gitlab::Zentao::Client do
it 'fetches the empty product' do
expect do
integration.fetch_product(zentao_integration.zentao_product_xid)
end.to raise_error(Gitlab::Zentao::Client::Error)
end.to raise_error(Gitlab::Zentao::Client::Error, 'request error')
end
end
......@@ -76,7 +76,7 @@ RSpec.describe Gitlab::Zentao::Client do
it 'fetches the empty product' do
expect do
integration.fetch_product(zentao_integration.zentao_product_xid)
end.to raise_error(Gitlab::Zentao::Client::Error)
end.to raise_error(Gitlab::Zentao::Client::Error, 'invalid response format')
end
end
end
......@@ -111,7 +111,8 @@ RSpec.describe Gitlab::Zentao::Client do
it 'returns empty object' do
invalid_ids.each do |id|
expect { integration.fetch_issue(id) }.to raise_error(Gitlab::Zentao::Client::Error)
expect { integration.fetch_issue(id) }
.to raise_error(Gitlab::Zentao::Client::Error, 'invalid issue id')
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment