Commit 5652ff95 authored by Dylan Griffith's avatar Dylan Griffith

Rename Runner#group? -> #assigned_to_group? and Runner#project? -> #assigned_to_project?

parent 8604dbe9
......@@ -137,11 +137,11 @@ module Ci
!shared?
end
def group?
def assigned_to_group?
runner_groups.any?
end
def project?
def assigned_to_project?
runner_projects.any?
end
......@@ -244,7 +244,7 @@ module Ci
errors.add(:runner, 'can only be assigned to one group')
end
if group? && project?
if assigned_to_group? && assigned_to_project?
errors.add(:runner, 'can only be assigned either to projects or to a group')
end
end
......
......@@ -17,7 +17,7 @@ module Ci
builds =
if runner.shared?
builds_for_shared_runner
elsif runner.group?
elsif runner.assigned_to_group?
builds_for_group_runner
else
builds_for_project_runner
......
......@@ -2,7 +2,7 @@
%td
- if runner.shared?
%span.label.label-success shared
- elsif runner.group?
- elsif runner.assigned_to_group?
%span.label.label-success group
- else
%span.label.label-info specific
......@@ -21,7 +21,7 @@
%td
= runner.ip_address
%td
- if runner.shared? || runner.group?
- if runner.shared? || runner.assigned_to_group?
n/a
- else
= runner.projects.count(:all)
......
......@@ -19,7 +19,7 @@
%p
If you want Runners to build only specific projects, enable them in the table below.
Keep in mind that this is a one way transition.
- elsif @runner.group?
- elsif @runner.assigned_to_group?
.bs-callout.bs-callout-success
%h4 This runner will process jobs from all projects in its group and subgroups
- else
......
......@@ -26,7 +26,7 @@
- else
- runner_project = @project.runner_projects.find_by(runner_id: runner)
= link_to 'Disable for this project', project_runner_project_path(@project, runner_project), data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm'
- elsif runner.project?
- elsif runner.assigned_to_project?
= form_for [@project.namespace.becomes(Namespace), @project, @project.runner_projects.new] do |f|
= f.hidden_field :runner_id, value: runner.id
= f.submit 'Enable for this project', class: 'btn btn-sm'
......
......@@ -205,7 +205,7 @@ module API
def authenticate_enable_runner!(runner)
forbidden!("Runner is shared") if runner.is_shared?
forbidden!("Runner is locked") if runner.locked?
forbidden!("Runner is a group runner") if runner.group?
forbidden!("Runner is a group runner") if runner.assigned_to_group?
return if current_user.admin?
forbidden!("No access granted") unless user_can_access_runner?(runner)
......
......@@ -748,47 +748,47 @@ describe Ci::Runner do
end
end
describe 'group?' do
describe 'assigned_to_group?' do
it 'returns false when the runner is a project runner' do
project = create :project
runner = create :ci_runner, description: 'Project runner', projects: [project]
expect(runner.group?).to be false
expect(runner.assigned_to_group?).to be false
end
it 'returns false when the runner is a shared runner' do
runner = create :ci_runner, :shared, description: 'Shared runner'
expect(runner.group?).to be false
expect(runner.assigned_to_group?).to be false
end
it 'returns true when the runner is assigned to a group' do
group = create :group
runner = create :ci_runner, description: 'Group runner', groups: [group]
expect(runner.group?).to be true
expect(runner.assigned_to_group?).to be true
end
end
describe 'project?' do
describe 'assigned_to_project?' do
it 'returns false when the runner is a group prunner' do
group = create :group
runner = create :ci_runner, description: 'Group runner', groups: [group]
expect(runner.project?).to be false
expect(runner.assigned_to_project?).to be false
end
it 'returns false when the runner is a shared runner' do
runner = create :ci_runner, :shared, description: 'Shared runner'
expect(runner.project?).to be false
expect(runner.assigned_to_project?).to be false
end
it 'returns true when the runner is assigned to a project' do
project = create :project
runner = create :ci_runner, description: 'Group runner', projects: [project]
expect(runner.project?).to be true
expect(runner.assigned_to_project?).to be true
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