Commit 1af0baf8 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'refactor/zentao_client/add_err_msg_when_raise' into 'master'

Add raise message to ZenTao client

See merge request gitlab-org/gitlab!72572
parents d1126e6d c36e5998
...@@ -33,7 +33,7 @@ module Gitlab ...@@ -33,7 +33,7 @@ module Gitlab
end end
def fetch_issue(issue_id) 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}") get("issues/#{issue_id}")
end end
...@@ -48,11 +48,11 @@ module Gitlab ...@@ -48,11 +48,11 @@ module Gitlab
options = { headers: headers, query: params } options = { headers: headers, query: params }
response = Gitlab::HTTP.get(url(path), options) 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) Gitlab::Json.parse(response.body)
rescue JSON::ParserError rescue JSON::ParserError
raise Gitlab::Zentao::Client::Error raise Gitlab::Zentao::Client::Error, 'invalid response format'
end end
def url(path) def url(path)
......
...@@ -63,7 +63,7 @@ RSpec.describe Gitlab::Zentao::Client do ...@@ -63,7 +63,7 @@ RSpec.describe Gitlab::Zentao::Client do
it 'fetches the empty product' do it 'fetches the empty product' do
expect do expect do
integration.fetch_product(zentao_integration.zentao_product_xid) 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
end end
...@@ -76,7 +76,7 @@ RSpec.describe Gitlab::Zentao::Client do ...@@ -76,7 +76,7 @@ RSpec.describe Gitlab::Zentao::Client do
it 'fetches the empty product' do it 'fetches the empty product' do
expect do expect do
integration.fetch_product(zentao_integration.zentao_product_xid) 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 end
end end
...@@ -111,7 +111,8 @@ RSpec.describe Gitlab::Zentao::Client do ...@@ -111,7 +111,8 @@ RSpec.describe Gitlab::Zentao::Client do
it 'returns empty object' do it 'returns empty object' do
invalid_ids.each do |id| 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 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