Commit 95c99cd4 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Admin should be able to turn shared runners into specific ones:

The regression was introduced by:

https://gitlab.com/gitlab-org/gitlab-ce/commit/1b8f52d9206bdf19c0dde04505c4c0b1cf46cfbe

I did that because there's a test specifying that a shared runner cannot
be enabled, in the API. So I assume that is the case for non-admin, but
admins should be able to do so anyway.

Also added a test to make sure this won't regress again.

Closes #19039
parent c9a46263
......@@ -4,7 +4,7 @@ class Admin::RunnerProjectsController < Admin::ApplicationController
def create
@runner = Ci::Runner.find(params[:runner_project][:runner_id])
return head(403) if @runner.is_shared? || @runner.locked?
return head(403) if @runner.locked?
runner_project = @runner.assign_to(@project, current_user)
......
......@@ -62,19 +62,35 @@ describe "Admin Runners" do
end
describe 'enable/create' do
before do
@project1.runners << runner
visit admin_runner_path(runner)
shared_examples 'enable runners' do
it 'enables a runner for a project' do
within '.unassigned-projects' do
click_on 'Enable'
end
assigned_project = page.find('.assigned-projects')
expect(assigned_project).to have_content(@project2.path)
end
end
it 'enables specific runner for project' do
within '.unassigned-projects' do
click_on 'Enable'
context 'with specific runner' do
before do
@project1.runners << runner
visit admin_runner_path(runner)
end
assigned_project = page.find('.assigned-projects')
it_behaves_like 'enable runners'
end
context 'with shared runner' do
before do
@project1.destroy
runner.update(is_shared: true)
visit admin_runner_path(runner)
end
expect(assigned_project).to have_content(@project2.path)
it_behaves_like 'enable runners'
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