Commit 8dad45a8 authored by Alexis Reigel's avatar Alexis Reigel

add method CI::Runner.project?

parent d6167a92
......@@ -146,6 +146,10 @@ module Ci
runner_groups.any?
end
def project?
runner_projects.any?
end
def can_pick?(build)
return false if self.ref_protected? && !build.protected?
......
......@@ -660,9 +660,7 @@ describe Ci::Runner do
describe 'group?' do
it 'returns false when the runner is a project runner' do
project = create :project
runner = create(:ci_runner, description: 'Project runner').tap do |r|
create :ci_runner_project, runner: r, project: project
end
runner = create :ci_runner, description: 'Project runner', projects: [project]
expect(runner.group?).to be false
end
......@@ -680,4 +678,26 @@ describe Ci::Runner do
expect(runner.group?).to be true
end
end
describe '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
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
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
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