add method CI::Runner.project?
This commit is contained in:
parent
d6167a9214
commit
8dad45a822
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue