diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-05-11 10:10:22 +0200 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-05-16 10:52:28 +0200 |
commit | b35d16a77f6a63db756a94eeff3788e819e7ed04 (patch) | |
tree | f0916f7aecaf44ef7150b5a832d202a5a05a190e | |
parent | 8583e4a1478ffe94dfd75c51c8480b323cada6df (diff) | |
download | gitlab-ce-b35d16a77f6a63db756a94eeff3788e819e7ed04.tar.gz |
Allow admin to assign shared runner to project through API
-rw-r--r-- | lib/api/runners.rb | 4 | ||||
-rw-r--r-- | spec/requests/api/runners_spec.rb | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/api/runners.rb b/lib/api/runners.rb index c6dc40ae789..0fb125a6944 100644 --- a/lib/api/runners.rb +++ b/lib/api/runners.rb @@ -203,11 +203,11 @@ module API end def authenticate_enable_runner!(runner) - forbidden!("Runner is shared") if runner.is_shared? - forbidden!("Runner is locked") if runner.locked? forbidden!("Runner is a group runner") if runner.group_type? + return if current_user.admin? + forbidden!("Runner is locked") if runner.locked? forbidden!("No access granted") unless can?(current_user, :assign_runner, runner) end diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb index 44eac4b2073..c7587c877fc 100644 --- a/spec/requests/api/runners_spec.rb +++ b/spec/requests/api/runners_spec.rb @@ -592,6 +592,15 @@ describe API::Runners do end.to change { project.runners.count }.by(+1) expect(response).to have_gitlab_http_status(201) end + + it 'enables a shared runner' do + expect do + post api("/projects/#{project.id}/runners", admin), runner_id: shared_runner.id + end.to change { project.runners.count }.by(1) + + expect(shared_runner.reload).not_to be_shared + expect(response).to have_gitlab_http_status(201) + end end context 'user is not admin' do |