Commit f811495e authored by James Lopez's avatar James Lopez

Merge branch '10-8-stable-prepare-rc8-fix-conflict-for-18874' into '10-8-stable-prepare-rc8'

Fixes conflict when picking into prep branch

See merge request gitlab-org/gitlab-ce!18900
parents 3a7d2859 7c3e42f0
Pipeline #21864808 failed with stages
in 29 minutes and 59 seconds
......@@ -107,7 +107,13 @@ module Ci
end
def assign_to(project, current_user = nil)
self.is_shared = false if shared?
if shared?
self.is_shared = false if shared?
self.runner_type = :project_type
elsif group_type?
raise ArgumentError, 'Transitioning a group runner to a project runner is not supported'
end
self.save
project.runner_projects.create(runner_id: self.id)
end
......
......@@ -198,16 +198,30 @@ describe Ci::Runner do
end
describe '#assign_to' do
let!(:project) { FactoryBot.create :project }
let!(:shared_runner) { FactoryBot.create(:ci_runner, :shared) }
let!(:project) { FactoryBot.create(:project) }
before do
shared_runner.assign_to(project)
subject { runner.assign_to(project) }
context 'with shared runner' do
let!(:runner) { FactoryBot.create(:ci_runner, :shared) }
it 'transitions shared runner to project runner and assigns project' do
subject
expect(runner).to be_specific
expect(runner).to be_project_type
expect(runner.projects).to eq([project])
expect(runner.only_for?(project)).to be_truthy
end
end
it { expect(shared_runner).to be_specific }
it { expect(shared_runner.projects).to eq([project]) }
it { expect(shared_runner.only_for?(project)).to be_truthy }
context 'with group runner' do
let!(:runner) { FactoryBot.create(:ci_runner, runner_type: :group_type) }
it 'raises an error' do
expect { subject }
.to raise_error(ArgumentError, 'Transitioning a group runner to a project runner is not supported')
end
end
end
describe '.online' 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