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
05eacd01
Commit
05eacd01
authored
Dec 20, 2017
by
Jarka Kadlecová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add API endpoint for ordering issue inside epic
parent
ba066b46
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
0 deletions
+105
-0
ee/lib/api/epic_issues.rb
ee/lib/api/epic_issues.rb
+40
-0
lib/api/api.rb
lib/api/api.rb
+1
-0
spec/ee/spec/requests/api/epic_issues_spec.rb
spec/ee/spec/requests/api/epic_issues_spec.rb
+64
-0
No files found.
ee/lib/api/epic_issues.rb
0 → 100644
View file @
05eacd01
module
API
class
EpicIssues
<
Grape
::
API
before
do
authenticate!
check_epics!
end
helpers
do
def
check_epics!
forbidden!
unless
::
License
.
feature_available?
(
:epics
)
# TODO: check for group feature instead
end
end
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a group'
end
resource
:groups
,
requirements:
API
::
PROJECT_ENDPOINT_REQUIREMENTS
do
desc
'Update epic issue association'
do
end
params
do
requires
:epic_iid
,
type:
Integer
,
desc:
'The iid of the epic'
requires
:epic_issue_id
,
type:
Integer
,
desc:
'The id of the epic issue association'
requires
:position
,
type:
Integer
,
desc:
'The new position of the issue in the epic (index starting with 0)'
end
put
':id/-/epics/:epic_iid/issues/:epic_issue_id'
do
epic
=
user_group
.
epics
.
find_by
(
iid:
params
[
:epic_iid
])
authorize!
(
:admin_epic
,
epic
)
link
=
EpicIssue
.
find
(
params
[
:epic_issue_id
])
forbidden!
if
link
.
epic
!=
epic
result
=
::
EpicIssues
::
UpdateService
.
new
(
link
,
current_user
,
{
position:
params
[
:position
].
to_i
}).
execute
render_api_error!
({
error:
"Issue could not be moved!"
},
400
)
unless
result
end
end
end
end
lib/api/api.rb
View file @
05eacd01
...
...
@@ -124,6 +124,7 @@ module API
mount
::
API
::
DeployKeys
mount
::
API
::
Deployments
mount
::
API
::
Environments
mount
::
API
::
EpicIssues
mount
::
API
::
Events
mount
::
API
::
Features
mount
::
API
::
Files
...
...
spec/ee/spec/requests/api/epic_issues_spec.rb
0 → 100644
View file @
05eacd01
require
'spec_helper'
describe
API
::
EpicIssues
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
let
(
:issues
)
{
create_list
(
:issue
,
2
,
project:
project
)
}
let!
(
:epic_issue1
)
{
create
(
:epic_issue
,
epic:
epic
,
issue:
issues
[
0
],
position:
1
)
}
describe
'PUT /groups/:id/-/epics/:epic_iid/issues/:epic_issue_id'
do
let
(
:url
)
{
"/groups/
#{
group
.
path
}
/-/epics/
#{
epic
.
iid
}
/issues/
#{
epic_issue1
.
id
}
?position=1"
}
context
'when an error occurs'
do
it
'returns 401 unauthorized error for non autehnticated user'
do
put
api
(
url
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
end
it
'returns 404 not found error for user who does not have permissions to see the group'
do
group
.
update
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
put
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
it
'returns 403 forbidden error for user who does can not move the issue'
do
group
.
update
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
put
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
it
'returns 403 forbidden error for the link of another epic'
do
group
.
add_developer
(
user
)
another_epic
=
create
(
:epic
,
group:
group
)
url
=
"/groups/
#{
group
.
path
}
/-/epics/
#{
another_epic
.
iid
}
/issues/
#{
epic_issue1
.
id
}
?position=1"
put
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
end
context
'when the request is correct'
do
let!
(
:epic_issue2
)
{
create
(
:epic_issue
,
epic:
epic
,
issue:
issues
[
1
],
position:
2
)
}
before
do
stub_licensed_features
(
epics:
true
)
group
.
add_developer
(
user
)
put
api
(
url
,
user
)
end
it
'returns 200 status'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
it
'updates the positions values'
do
expect
(
epic_issue1
.
reload
.
position
).
to
eq
(
2
)
expect
(
epic_issue2
.
reload
.
position
).
to
eq
(
1
)
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