diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-06-14 23:05:33 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-06-14 23:05:33 +0800 |
commit | 6c500034f4e626f28fa0a47534c24f7181131b43 (patch) | |
tree | 9269501787f26868f69a496eb9694104e6ae3d17 /lib/api/runners.rb | |
parent | fd285f71d8da46e76719a1055f168cd0b7e45094 (diff) | |
parent | f74f42386029077d0f12ac407fc6ee39aaeeaf53 (diff) | |
download | gitlab-ce-6c500034f4e626f28fa0a47534c24f7181131b43.tar.gz |
Merge branch 'prefer-assign_to' into feature/runner-lock-on-project
* prefer-assign_to:
Give 409 Conflict whenever the runner was already enabled
We're checking return value rather than rescuing exceptions
Prefer Runner#assign_to instead of creating directly
Diffstat (limited to 'lib/api/runners.rb')
-rw-r--r-- | lib/api/runners.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/api/runners.rb b/lib/api/runners.rb index 3ae228d61d8..2c2610fc2e7 100644 --- a/lib/api/runners.rb +++ b/lib/api/runners.rb @@ -96,9 +96,12 @@ module API runner = get_runner(params[:runner_id]) authenticate_enable_runner!(runner) - Ci::RunnerProject.create(runner: runner, project: user_project) - present runner, with: Entities::Runner + if runner.assign_to(user_project) + present runner, with: Entities::Runner + else + conflict!("Runner was already enabled for this project") + end end # Disable project's runner |