Commit 7d5a1826 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Use POST method instead of DELETE when erasing a build

Discussion:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/2560#note_3742042
parent 08b8f489
......@@ -122,7 +122,7 @@
- if @build.erasable?
= link_to erase_namespace_project_build_path(@project.namespace, @project, @build),
class: 'btn btn-sm btn-warning', method: :delete,
class: 'btn btn-sm btn-warning', method: :post,
data: { confirm: 'Are you sure you want to erase this build?' } do
= icon('eraser')
Erase
......
......@@ -617,7 +617,7 @@ Rails.application.routes.draw do
get :status
post :cancel
post :retry
delete :erase, path: :content
post :erase
end
resource :artifacts, only: [] do
......
......@@ -344,20 +344,20 @@ Example of response
Erase a single build of a project (remove build artifacts and a build trace)
```
DELETE /projects/:id/builds/:build_id/content
POST /projects/:id/builds/:build_id/erase
```
Parameters
| Attribute | Type | required | Description |
|-----------|---------|----------|---------------------|
| Attribute | Type | required | Description |
|-------------|---------|----------|---------------------|
| `id` | integer | yes | The ID of a project |
| `build_id` | integer | yes | The ID of a build |
| `build_id` | integer | yes | The ID of a build |
Example of request
```
curl -X DELETE -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/1/content"
curl -X POST -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/1/erase"
```
Example of response
......
......@@ -130,15 +130,15 @@ module API
# id (required) - the id of a project
# build_id (required) - the id of a build
# example Request:
# delete /projects/:id/build/:build_id/content
delete ':id/builds/:build_id/content' do
# post /projects/:id/build/:build_id/erase
post ':id/builds/:build_id/erase' do
authorize_update_builds!
build = get_build(params[:build_id])
return not_found!(build) unless build
return forbidden!('Build is not erasable!') unless build.erasable?
build.erase!
build.erase
present build, with: Entities::Build,
user_can_download_artifacts: can?(current_user, :download_build_artifacts, user_project)
end
......
......@@ -170,16 +170,16 @@ describe API::API, api: true do
end
end
describe 'DELETE /projects/:id/builds/:build_id/content' do
describe 'POST /projects/:id/builds/:build_id/erase' do
before do
delete api("/projects/#{project.id}/builds/#{build.id}/content", user)
post api("/projects/#{project.id}/builds/#{build.id}/erase", user)
end
context 'build is erasable' do
let(:build) { create(:ci_build_with_trace, :artifacts, :success, project: project, commit: commit) }
it 'should erase build content' do
expect(response.status).to eq 200
expect(response.status).to eq 201
expect(build.trace).to be_empty
expect(build.artifacts_file.exists?).to be_falsy
expect(build.artifacts_metadata.exists?).to be_falsy
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment