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
eb9cddbe
Commit
eb9cddbe
authored
Jun 21, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return correct error messages / http statuses for the public API
parent
7078ab9e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
17 additions
and
15 deletions
+17
-15
app/services/issue_links/create_service.rb
app/services/issue_links/create_service.rb
+1
-1
app/services/issue_links/destroy_service.rb
app/services/issue_links/destroy_service.rb
+1
-1
lib/api/issue_links.rb
lib/api/issue_links.rb
+5
-3
spec/requests/api/issue_links_spec.rb
spec/requests/api/issue_links_spec.rb
+3
-3
spec/requests/projects/issue_links_controller_spec.rb
spec/requests/projects/issue_links_controller_spec.rb
+3
-3
spec/services/issue_links/create_service_spec.rb
spec/services/issue_links/create_service_spec.rb
+3
-3
spec/services/issue_links/destroy_service_spec.rb
spec/services/issue_links/destroy_service_spec.rb
+1
-1
No files found.
app/services/issue_links/create_service.rb
View file @
eb9cddbe
...
...
@@ -6,7 +6,7 @@ module IssueLinks
def
execute
if
referenced_issues
.
blank?
return
error
(
'No Issue found for given params'
,
40
1
)
return
error
(
'No Issue found for given params'
,
40
4
)
end
create_issue_links
...
...
app/services/issue_links/destroy_service.rb
View file @
eb9cddbe
...
...
@@ -8,7 +8,7 @@ module IssueLinks
end
def
execute
return
error
(
'
Unauthorized'
,
401
)
unless
permission_to_remove_relation?
return
error
(
'
No Issue Link found'
,
404
)
unless
permission_to_remove_relation?
remove_relation
create_notes
...
...
lib/api/issue_links.rb
View file @
eb9cddbe
...
...
@@ -31,7 +31,6 @@ module API
end
post
':id/issues/:issue_iid/links'
do
source_issue
=
find_project_issue
(
params
[
:issue_iid
])
target_issue
=
find_project_issue
(
declared_params
[
:target_issue_iid
],
declared_params
[
:target_project_id
])
...
...
@@ -46,7 +45,7 @@ module API
present
issue_link
,
with:
Entities
::
IssueLink
else
not_found!
render_api_error!
(
result
[
:message
],
result
[
:http_status
])
end
end
...
...
@@ -59,6 +58,9 @@ module API
delete
':id/issues/:issue_iid/links/:issue_link_id'
do
issue_link
=
IssueLink
.
find
(
declared_params
[
:issue_link_id
])
find_project_issue
(
params
[
:issue_iid
])
find_project_issue
(
issue_link
.
target
.
iid
.
to_s
,
issue_link
.
target
.
project_id
.
to_s
)
result
=
::
IssueLinks
::
DestroyService
.
new
(
issue_link
,
current_user
)
.
execute
...
...
@@ -66,7 +68,7 @@ module API
if
result
[
:status
]
==
:success
present
issue_link
,
with:
Entities
::
IssueLink
else
not_found!
render_api_error!
(
result
[
:message
],
result
[
:http_status
])
end
end
end
...
...
spec/requests/api/issue_links_spec.rb
View file @
eb9cddbe
...
...
@@ -80,7 +80,7 @@ describe API::IssueLinks do
target_project_id:
unauthorized_project
.
id
,
target_issue_iid:
target_issue
.
iid
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'
404 Not Found
'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'
No Issue found for given params
'
)
end
end
...
...
@@ -158,7 +158,7 @@ describe API::IssueLinks do
delete
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/links/
#{
issue_link
.
id
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'
404 Not F
ound'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'
No Issue Link f
ound'
)
end
end
...
...
@@ -180,7 +180,7 @@ describe API::IssueLinks do
delete
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/links/
#{
issue_link
.
id
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not Found'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404
Project
Not Found'
)
end
end
...
...
spec/requests/projects/issue_links_controller_spec.rb
View file @
eb9cddbe
...
...
@@ -73,7 +73,7 @@ describe Projects::IssueLinksController do
list_service_response
=
IssueLinks
::
ListService
.
new
(
issue
,
user
).
execute
expect
(
response
).
to
have_http_status
(
40
1
)
expect
(
response
).
to
have_http_status
(
40
4
)
expect
(
json_response
).
to
eq
(
'message'
=>
'No Issue found for given params'
,
'issues'
=>
list_service_response
.
as_json
)
end
end
...
...
@@ -105,10 +105,10 @@ describe Projects::IssueLinksController do
let
(
:referenced_issue
)
{
create
:issue
}
let
(
:user_role
)
{
:developer
}
it
'returns 40
1
'
do
it
'returns 40
4
'
do
delete
namespace_project_issue_link_path
(
issue_links_params
(
id:
issue_link
.
id
))
expect
(
response
).
to
have_http_status
(
40
1
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
end
end
...
...
spec/services/issue_links/create_service_spec.rb
View file @
eb9cddbe
...
...
@@ -25,7 +25,7 @@ describe IssueLinks::CreateService, service: true do
end
it
'returns error'
do
is_expected
.
to
eq
(
message:
'No Issue found for given params'
,
status: :error
,
http_status:
40
1
)
is_expected
.
to
eq
(
message:
'No Issue found for given params'
,
status: :error
,
http_status:
40
4
)
end
end
...
...
@@ -35,7 +35,7 @@ describe IssueLinks::CreateService, service: true do
end
it
'returns error'
do
is_expected
.
to
eq
(
message:
'No Issue found for given params'
,
status: :error
,
http_status:
40
1
)
is_expected
.
to
eq
(
message:
'No Issue found for given params'
,
status: :error
,
http_status:
40
4
)
end
it
'no relationship is created'
do
...
...
@@ -53,7 +53,7 @@ describe IssueLinks::CreateService, service: true do
it
'returns error'
do
target_issue
.
project
.
add_guest
(
user
)
is_expected
.
to
eq
(
message:
'No Issue found for given params'
,
status: :error
,
http_status:
40
1
)
is_expected
.
to
eq
(
message:
'No Issue found for given params'
,
status: :error
,
http_status:
40
4
)
end
it
'no relationship is created'
do
...
...
spec/services/issue_links/destroy_service_spec.rb
View file @
eb9cddbe
...
...
@@ -52,7 +52,7 @@ describe IssueLinks::DestroyService, service: true do
end
it
'returns error message'
do
is_expected
.
to
eq
(
message:
'
Unauthorized'
,
status: :error
,
http_status:
401
)
is_expected
.
to
eq
(
message:
'
No Issue Link found'
,
status: :error
,
http_status:
404
)
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