Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c36e5998
Commit
c36e5998
authored
Oct 21, 2021
by
Baodong
Committed by
Mayra Cabrera
Oct 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add raise message to ZenTao client
parent
aaa154be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
lib/gitlab/zentao/client.rb
lib/gitlab/zentao/client.rb
+3
-3
spec/lib/gitlab/zentao/client_spec.rb
spec/lib/gitlab/zentao/client_spec.rb
+4
-3
No files found.
lib/gitlab/zentao/client.rb
View file @
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
)
...
...
spec/lib/gitlab/zentao/client_spec.rb
View file @
c36e5998
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment