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
3e38d6a5
Commit
3e38d6a5
authored
Jun 21, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render 404 whenever we cannot find or not authorized Issue/IssueLink
parent
8a7b8c7d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
19 deletions
+26
-19
lib/api/issue_links.rb
lib/api/issue_links.rb
+2
-2
spec/requests/api/issue_links_spec.rb
spec/requests/api/issue_links_spec.rb
+15
-8
spec/services/issue_links/destroy_service_spec.rb
spec/services/issue_links/destroy_service_spec.rb
+9
-9
No files found.
lib/api/issue_links.rb
View file @
3e38d6a5
...
...
@@ -46,7 +46,7 @@ module API
present
issue_link
,
with:
Entities
::
IssueLink
else
render_api_error!
(
result
[
:message
],
result
[
:http_status
])
not_found!
end
end
...
...
@@ -66,7 +66,7 @@ module API
if
result
[
:status
]
==
:success
present
issue_link
,
with:
Entities
::
IssueLink
else
render_api_error!
(
result
[
:message
],
result
[
:http_status
])
not_found!
end
end
end
...
...
spec/requests/api/issue_links_spec.rb
View file @
3e38d6a5
...
...
@@ -54,22 +54,24 @@ describe API::IssueLinks do
target_project_id:
999
,
target_issue_iid:
target_issue
.
iid
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Project Not Found'
)
end
end
context
'given target issue not found'
do
it
'returns 404'
do
target_project
=
create
(
:empty_project
)
target_project
=
create
(
:empty_project
,
:public
)
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/links"
,
user
),
target_project_id:
target_project
.
id
,
target_issue_iid:
999
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
end
context
'when user does not have write access to given issue'
do
it
'returns 40
1
'
do
it
'returns 40
4
'
do
unauthorized_project
=
create
(
:empty_project
)
target_issue
=
create
(
:issue
,
project:
unauthorized_project
)
unauthorized_project
.
add_guest
(
user
)
...
...
@@ -77,8 +79,8 @@ describe API::IssueLinks do
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/links"
,
user
),
target_project_id:
unauthorized_project
.
id
,
target_issue_iid:
target_issue
.
iid
expect
(
response
).
to
have_http_status
(
40
1
)
expect
(
json_response
[
'message'
]).
to
eq
(
'
No Issue found for given params
'
)
expect
(
response
).
to
have_http_status
(
40
4
)
expect
(
json_response
[
'message'
]).
to
eq
(
'
404 Not Found
'
)
end
end
...
...
@@ -91,6 +93,7 @@ describe API::IssueLinks do
target_project_id:
project
.
id
,
target_issue_iid:
target_issue
.
iid
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
end
...
...
@@ -103,6 +106,7 @@ describe API::IssueLinks do
target_project_id:
project
.
id
,
target_issue_iid:
target_issue
.
iid
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Project Not Found'
)
end
end
...
...
@@ -145,7 +149,7 @@ describe API::IssueLinks do
context
'when authenticated'
do
context
'when user does not have write access to given issue link'
do
it
'returns 40
1
'
do
it
'returns 40
4
'
do
unauthorized_project
=
create
(
:empty_project
)
target_issue
=
create
(
:issue
,
project:
unauthorized_project
)
issue_link
=
create
(
:issue_link
,
source:
issue
,
target:
target_issue
)
...
...
@@ -153,7 +157,8 @@ describe API::IssueLinks do
delete
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/links/
#{
issue_link
.
id
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
401
)
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not Found'
)
end
end
...
...
@@ -162,18 +167,20 @@ describe API::IssueLinks do
delete
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/links/999"
,
user
)
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
end
context
'when trying to delete a link with a private project issue'
do
it
'returns 40
1
'
do
it
'returns 40
4
'
do
project
=
create
(
:empty_project
,
:private
)
target_issue
=
create
(
:issue
,
project:
project
)
issue_link
=
create
(
:issue_link
,
source:
issue
,
target:
target_issue
)
delete
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/links/
#{
issue_link
.
id
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
401
)
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not Found'
)
end
end
...
...
spec/services/issue_links/destroy_service_spec.rb
View file @
3e38d6a5
...
...
@@ -2,16 +2,16 @@ require 'spec_helper'
describe
IssueLinks
::
DestroyService
,
service:
true
do
describe
'#execute'
do
let
(
:project
)
{
create
:empty_project
}
let
(
:user
)
{
create
:user
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
subject
{
described_class
.
new
(
issue_link
,
user
).
execute
}
context
'when successfully removes an issue link'
do
let
(
:issue_a
)
{
create
:issue
,
project:
project
}
let
(
:issue_b
)
{
create
:issue
,
project:
project
}
let
(
:issue_a
)
{
create
(
:issue
,
project:
project
)
}
let
(
:issue_b
)
{
create
(
:issue
,
project:
project
)
}
let!
(
:issue_link
)
{
create
:issue_link
,
source:
issue_a
,
target:
issue_b
}
let!
(
:issue_link
)
{
create
(
:issue_link
,
source:
issue_a
,
target:
issue_b
)
}
before
do
project
.
add_reporter
(
user
)
...
...
@@ -37,11 +37,11 @@ describe IssueLinks::DestroyService, service: true do
end
context
'when failing to remove an issue link'
do
let
(
:unauthorized_project
)
{
create
:empty_project
}
let
(
:issue_a
)
{
create
:issue
,
project:
project
}
let
(
:issue_b
)
{
create
:issue
,
project:
unauthorized_project
}
let
(
:unauthorized_project
)
{
create
(
:empty_project
)
}
let
(
:issue_a
)
{
create
(
:issue
,
project:
project
)
}
let
(
:issue_b
)
{
create
(
:issue
,
project:
unauthorized_project
)
}
let!
(
:issue_link
)
{
create
:issue_link
,
source:
issue_a
,
target:
issue_b
}
let!
(
:issue_link
)
{
create
(
:issue_link
,
source:
issue_a
,
target:
issue_b
)
}
it
'does not remove relation'
do
expect
{
subject
}.
not_to
change
(
IssueLink
,
:count
).
from
(
1
)
...
...
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