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 ...@@ -4,7 +4,7 @@ class Admin::RunnerProjectsController < Admin::ApplicationController
def create def create
@runner = Ci::Runner.find(params[:runner_project][:runner_id]) @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) runner_project = @runner.assign_to(@project, current_user)
......
...@@ -62,19 +62,35 @@ describe "Admin Runners" do ...@@ -62,19 +62,35 @@ describe "Admin Runners" do
end end
describe 'enable/create' do describe 'enable/create' do
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
context 'with specific runner' do
before do before do
@project1.runners << runner @project1.runners << runner
visit admin_runner_path(runner) visit admin_runner_path(runner)
end end
it 'enables specific runner for project' do it_behaves_like 'enable runners'
within '.unassigned-projects' do
click_on 'Enable'
end end
assigned_project = page.find('.assigned-projects') 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
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