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