Commit f74f4238 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Give 409 Conflict whenever the runner was already enabled

parent 1b03c580
......@@ -40,6 +40,7 @@ v 8.9.0 (unreleased)
- Added artifacts:when to .gitlab-ci.yml - this requires GitLab Runner 1.3
- Todos will display target state if issuable target is 'Closed' or 'Merged'
- Fix bug when sorting issues by milestone due date and filtering by two or more labels
- POST to API /projects/:id/runners/:runner_id would give 409 if the runner was already enabled for this project
- Add support for using Yubikeys (U2F) for two-factor authentication
- Link to blank group icon doesn't throw a 404 anymore
- Remove 'main language' feature
......
......@@ -56,7 +56,7 @@ module Ci
def assign_to(project, current_user = nil)
self.is_shared = false if shared?
self.save
project.runner_projects.create(runner_id: self.id)
project.runner_projects.create(runner_id: self.id).persisted?
end
def display_name
......
......@@ -96,9 +96,12 @@ module API
runner = get_runner(params[:runner_id])
authenticate_enable_runner!(runner)
runner.assign_to(user_project)
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
......
......@@ -375,7 +375,7 @@ describe API::Runners, api: true do
expect do
post api("/projects/#{project.id}/runners", user), runner_id: specific_runner.id
end.to change{ project.runners.count }.by(0)
expect(response.status).to eq(201)
expect(response.status).to eq(409)
end
it 'should not enable shared runner' do
......
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