Commit d5f70604 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Rename `/take` to `/take_ownership`, expose `owner` in `v3`.

parent 01f99bd2
...@@ -128,7 +128,7 @@ curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form descrip ...@@ -128,7 +128,7 @@ curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form descrip
Update an owner of a project trigger. Update an owner of a project trigger.
``` ```
POST /projects/:id/triggers/:trigger_id/take POST /projects/:id/triggers/:trigger_id/take_ownership
``` ```
| Attribute | Type | required | Description | | Attribute | Type | required | Description |
...@@ -136,7 +136,7 @@ POST /projects/:id/triggers/:trigger_id/take ...@@ -136,7 +136,7 @@ POST /projects/:id/triggers/:trigger_id/take
| `trigger_id` | integer | yes | The trigger id | | `trigger_id` | integer | yes | The trigger id |
``` ```
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/1/triggers/10/take" curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/1/triggers/10/take_ownership"
``` ```
```json ```json
......
...@@ -114,7 +114,7 @@ module API ...@@ -114,7 +114,7 @@ module API
params do params do
requires :trigger_id, type: Integer, desc: 'The trigger ID' requires :trigger_id, type: Integer, desc: 'The trigger ID'
end end
post ':id/triggers/:trigger_id/take' do post ':id/triggers/:trigger_id/take_ownership' do
authenticate! authenticate!
authorize! :admin_build, user_project authorize! :admin_build, user_project
......
...@@ -189,6 +189,7 @@ module API ...@@ -189,6 +189,7 @@ module API
class Trigger < Grape::Entity class Trigger < Grape::Entity
expose :token, :created_at, :updated_at, :deleted_at, :last_used expose :token, :created_at, :updated_at, :deleted_at, :last_used
expose :owner, using: Entities::UserBasic
end end
class TriggerRequest < Grape::Entity class TriggerRequest < Grape::Entity
......
...@@ -238,12 +238,12 @@ describe API::Triggers do ...@@ -238,12 +238,12 @@ describe API::Triggers do
end end
end end
describe 'POST /projects/:id/triggers/:trigger_id/take' do describe 'POST /projects/:id/triggers/:trigger_id/take_ownership' do
context 'authenticated user with valid permissions' do context 'authenticated user with valid permissions' do
it 'updates owner' do it 'updates owner' do
expect(trigger.owner).to be_nil expect(trigger.owner).to be_nil
post api("/projects/#{project.id}/triggers/#{trigger.id}/take", user) post api("/projects/#{project.id}/triggers/#{trigger.id}/take_ownership", user)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response).to include('owner') expect(json_response).to include('owner')
...@@ -253,7 +253,7 @@ describe API::Triggers do ...@@ -253,7 +253,7 @@ describe API::Triggers do
context 'authenticated user with invalid permissions' do context 'authenticated user with invalid permissions' do
it 'does not update owner' do it 'does not update owner' do
post api("/projects/#{project.id}/triggers/#{trigger.id}/take", user2) post api("/projects/#{project.id}/triggers/#{trigger.id}/take_ownership", user2)
expect(response).to have_http_status(403) expect(response).to have_http_status(403)
end end
...@@ -261,7 +261,7 @@ describe API::Triggers do ...@@ -261,7 +261,7 @@ describe API::Triggers do
context 'unauthenticated user' do context 'unauthenticated user' do
it 'does not update owner' do it 'does not update owner' do
post api("/projects/#{project.id}/triggers/#{trigger.id}/take") post api("/projects/#{project.id}/triggers/#{trigger.id}/take_ownership")
expect(response).to have_http_status(401) expect(response).to have_http_status(401)
end end
......
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