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
49474df5
Commit
49474df5
authored
Mar 26, 2020
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix HTTP status code for Todos API when an epic cannot be found
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
1cef19ba
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
15 deletions
+14
-15
ee/changelogs/unreleased/fix-http-status-code-in-epic-todos-api.yml
...ogs/unreleased/fix-http-status-code-in-epic-todos-api.yml
+5
-0
ee/lib/ee/api/helpers.rb
ee/lib/ee/api/helpers.rb
+2
-5
ee/lib/ee/api/todos.rb
ee/lib/ee/api/todos.rb
+2
-7
ee/spec/requests/api/todos_spec.rb
ee/spec/requests/api/todos_spec.rb
+1
-1
lib/api/helpers.rb
lib/api/helpers.rb
+4
-2
No files found.
ee/changelogs/unreleased/fix-http-status-code-in-epic-todos-api.yml
0 → 100644
View file @
49474df5
---
title
:
Fix HTTP status code for Todos API when an epic cannot be found
merge_request
:
28310
author
:
type
:
fixed
ee/lib/ee/api/helpers.rb
View file @
49474df5
...
...
@@ -104,12 +104,9 @@ module EE
end
end
override
:find_project_issue
# rubocop: disable CodeReuse/ActiveRecord
def
find_project_issue
(
iid
,
project_id
=
nil
)
project
=
project_id
?
find_project!
(
project_id
)
:
user_project
::
IssuesFinder
.
new
(
current_user
,
project_id:
project
.
id
).
find_by!
(
iid:
iid
)
def
find_group_epic
(
iid
)
EpicsFinder
.
new
(
current_user
,
group_id:
user_group
.
id
).
find_by!
(
iid:
iid
)
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
ee/lib/ee/api/todos.rb
View file @
49474df5
...
...
@@ -9,14 +9,8 @@ module EE
helpers
do
extend
::
Gitlab
::
Utils
::
Override
# rubocop: disable CodeReuse/ActiveRecord
def
epic
@epic
||=
user_group
.
epics
.
find_by
(
iid:
params
[
:epic_iid
])
end
# rubocop: enable CodeReuse/ActiveRecord
def
authorize_can_read!
authorize!
(
:read_epic
,
epic
)
authorize!
(
:read_epic
,
user_group
)
end
end
...
...
@@ -29,6 +23,7 @@ module EE
end
post
":id/epics/:epic_iid/todo"
do
authorize_can_read!
epic
=
find_group_epic
(
params
[
:epic_iid
])
todo
=
::
TodoService
.
new
.
mark_todo
(
epic
,
current_user
).
first
if
todo
...
...
ee/spec/requests/api/todos_spec.rb
View file @
49474df5
...
...
@@ -142,7 +142,7 @@ describe API::Todos do
post
api
(
"/groups/
#{
group
.
id
}
/epics/
#{
non_existing_record_iid
}
/todo"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
:
forbidden
)
expect
(
response
).
to
have_gitlab_http_status
(
:
not_found
)
end
it
'returns an error if the epic is not accessible'
do
...
...
lib/api/helpers.rb
View file @
49474df5
...
...
@@ -179,8 +179,10 @@ module API
end
# rubocop: disable CodeReuse/ActiveRecord
def
find_project_issue
(
iid
)
IssuesFinder
.
new
(
current_user
,
project_id:
user_project
.
id
).
find_by!
(
iid:
iid
)
def
find_project_issue
(
iid
,
project_id
=
nil
)
project
=
project_id
?
find_project!
(
project_id
)
:
user_project
::
IssuesFinder
.
new
(
current_user
,
project_id:
project
.
id
).
find_by!
(
iid:
iid
)
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
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