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
ee743909
Commit
ee743909
authored
Apr 27, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Returns 404 on removal when no authorization on the related issue project
parent
b8587050
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
7 deletions
+24
-7
app/controllers/projects/related_issues_controller.rb
app/controllers/projects/related_issues_controller.rb
+5
-0
spec/controllers/projects/related_issues_controller_spec.rb
spec/controllers/projects/related_issues_controller_spec.rb
+19
-7
No files found.
app/controllers/projects/related_issues_controller.rb
View file @
ee743909
...
@@ -16,6 +16,11 @@ module Projects
...
@@ -16,6 +16,11 @@ module Projects
def
destroy
def
destroy
related_issue
=
RelatedIssue
.
find
(
params
[
:id
])
related_issue
=
RelatedIssue
.
find
(
params
[
:id
])
# In order to remove a given relation, one must be allowed to admin_related_issue both the current
# project and on the related issue project.
return
render_404
unless
can?
(
current_user
,
:admin_related_issue
,
related_issue
.
related_issue
.
project
)
result
=
RelatedIssues
::
DestroyService
.
new
(
related_issue
,
current_user
).
execute
result
=
RelatedIssues
::
DestroyService
.
new
(
related_issue
,
current_user
).
execute
render
json:
result
render
json:
result
...
...
spec/controllers/projects/related_issues_controller_spec.rb
View file @
ee743909
...
@@ -82,10 +82,11 @@ describe Projects::RelatedIssuesController, type: :controller do
...
@@ -82,10 +82,11 @@ describe Projects::RelatedIssuesController, type: :controller do
end
end
describe
'DELETE #destroy'
do
describe
'DELETE #destroy'
do
let
(
:related_issue
)
{
create
:related_issue
}
let
(
:referenced_issue
)
{
create
:issue
,
project:
project
}
let
(
:related_issue
)
{
create
:related_issue
,
related_issue:
referenced_issue
}
let
(
:service
)
{
double
(
RelatedIssues
::
DestroyService
,
execute:
service_response
)
}
let
(
:service
)
{
double
(
RelatedIssues
::
DestroyService
,
execute:
service_response
)
}
let
(
:service_response
)
{
{
'message'
=>
'yay'
}
}
let
(
:service_response
)
{
{
'message'
=>
'yay'
}
}
let
(
:user_role
)
{
:developer
}
let
(
:
current_project_
user_role
)
{
:developer
}
subject
do
subject
do
delete
:destroy
,
namespace_id:
issue
.
project
.
namespace
,
delete
:destroy
,
namespace_id:
issue
.
project
.
namespace
,
...
@@ -96,7 +97,7 @@ describe Projects::RelatedIssuesController, type: :controller do
...
@@ -96,7 +97,7 @@ describe Projects::RelatedIssuesController, type: :controller do
end
end
before
do
before
do
project
.
team
<<
[
user
,
user_role
]
project
.
team
<<
[
user
,
current_project_
user_role
]
sign_in
user
sign_in
user
allow
(
RelatedIssues
::
DestroyService
).
to
receive
(
:new
)
allow
(
RelatedIssues
::
DestroyService
).
to
receive
(
:new
)
...
@@ -105,15 +106,26 @@ describe Projects::RelatedIssuesController, type: :controller do
...
@@ -105,15 +106,26 @@ describe Projects::RelatedIssuesController, type: :controller do
end
end
context
'when unauthorized'
do
context
'when unauthorized'
do
let
(
:user_role
)
{
:guest
}
context
'when no authorization on current project'
do
let
(
:current_project_user_role
)
{
:guest
}
it
'returns 404'
do
it
'returns 404'
do
is_expected
.
to
have_http_status
(
404
)
is_expected
.
to
have_http_status
(
404
)
end
end
context
'when no authorization on the related issue project'
do
let
(
:referenced_issue
)
{
create
:issue
}
let
(
:current_project_user_role
)
{
:developer
}
it
'returns 404'
do
is_expected
.
to
have_http_status
(
404
)
end
end
end
end
end
context
'when authorized'
do
context
'when authorized'
do
let
(
:user_role
)
{
:developer
}
let
(
:
current_project_
user_role
)
{
:developer
}
it
'returns success JSON'
do
it
'returns success JSON'
do
is_expected
.
to
have_http_status
(
200
)
is_expected
.
to
have_http_status
(
200
)
...
...
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