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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
d3425933
Commit
d3425933
authored
Feb 21, 2017
by
Mark Fletcher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add housekeeping endpoint for Projects API
parent
459a97d4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
0 deletions
+80
-0
changelogs/unreleased/27032-add-a-house-keeping-api-call.yml
changelogs/unreleased/27032-add-a-house-keeping-api-call.yml
+4
-0
doc/api/projects.md
doc/api/projects.md
+14
-0
lib/api/projects.rb
lib/api/projects.rb
+13
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+49
-0
No files found.
changelogs/unreleased/27032-add-a-house-keeping-api-call.yml
0 → 100644
View file @
d3425933
---
title
:
Add housekeeping endpoint for Projects API
merge_request
:
9421
author
:
doc/api/projects.md
View file @
d3425933
...
@@ -1195,3 +1195,17 @@ Parameters:
...
@@ -1195,3 +1195,17 @@ Parameters:
|
`query`
| string | yes | A string contained in the project name |
|
`query`
| string | yes | A string contained in the project name |
|
`order_by`
| string | no | Return requests ordered by
`id`
,
`name`
,
`created_at`
or
`last_activity_at`
fields |
|
`order_by`
| string | no | Return requests ordered by
`id`
,
`name`
,
`created_at`
or
`last_activity_at`
fields |
|
`sort`
| string | no | Return requests sorted in
`asc`
or
`desc`
order |
|
`sort`
| string | no | Return requests sorted in
`asc`
or
`desc`
order |
## Start the Housekeeping task for a Project
>**Note:** This feature was introduced in GitLab 9.0
```
POST /projects/:id/housekeeping
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`id`
| integer/string | yes | The ID of the project or NAMESPACE/PROJECT_NAME |
lib/api/projects.rb
View file @
d3425933
...
@@ -374,6 +374,19 @@ module API
...
@@ -374,6 +374,19 @@ module API
present
paginate
(
users
),
with:
Entities
::
UserBasic
present
paginate
(
users
),
with:
Entities
::
UserBasic
end
end
desc
'Start the housekeeping task for a project'
do
detail
'This feature was introduced in GitLab 9.0.'
end
post
':id/housekeeping'
do
authorize_admin_project
begin
::
Projects
::
HousekeepingService
.
new
(
user_project
).
execute
rescue
::
Projects
::
HousekeepingService
::
LeaseTaken
=>
error
conflict!
(
error
.
message
)
end
end
end
end
end
end
end
end
spec/requests/api/projects_spec.rb
View file @
d3425933
...
@@ -1422,4 +1422,53 @@ describe API::Projects, api: true do
...
@@ -1422,4 +1422,53 @@ describe API::Projects, api: true do
end
end
end
end
end
end
describe
'POST /projects/:id/housekeeping'
do
let
(
:housekeeping
)
{
Projects
::
HousekeepingService
.
new
(
project
)
}
before
do
allow
(
Projects
::
HousekeepingService
).
to
receive
(
:new
).
with
(
project
).
and_return
(
housekeeping
)
end
context
'when authenticated as owner'
do
it
'starts the housekeeping process'
do
expect
(
housekeeping
).
to
receive
(
:execute
).
once
post
api
(
"/projects/
#{
project
.
id
}
/housekeeping"
,
user
)
expect
(
response
).
to
have_http_status
(
201
)
end
context
'when housekeeping lease is taken'
do
it
'returns conflict'
do
expect
(
housekeeping
).
to
receive
(
:execute
).
once
.
and_raise
(
Projects
::
HousekeepingService
::
LeaseTaken
)
post
api
(
"/projects/
#{
project
.
id
}
/housekeeping"
,
user
)
expect
(
response
).
to
have_http_status
(
409
)
expect
(
json_response
[
'message'
]).
to
match
(
/Somebody already triggered housekeeping for this project/
)
end
end
end
context
'when authenticated as developer'
do
before
do
project_member2
end
it
'returns forbidden error'
do
post
api
(
"/projects/
#{
project
.
id
}
/housekeeping"
,
user3
)
expect
(
response
).
to
have_http_status
(
403
)
end
end
context
'when unauthenticated'
do
it
'returns authentication error'
do
post
api
(
"/projects/
#{
project
.
id
}
/housekeeping"
)
expect
(
response
).
to
have_http_status
(
401
)
end
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