Add method that check if build has tags
This commit is contained in:
parent
8252333183
commit
8001eed06e
|
@ -290,13 +290,15 @@ module Ci
|
|||
end
|
||||
|
||||
def can_be_served?(runner)
|
||||
if tag_list.empty? && !runner.run_untagged?
|
||||
return false
|
||||
end
|
||||
return false unless has_tags? || runner.run_untagged?
|
||||
|
||||
(tag_list - runner.tag_list).empty?
|
||||
end
|
||||
|
||||
def has_tags?
|
||||
tag_list.any?
|
||||
end
|
||||
|
||||
def any_runners_online?
|
||||
project.any_runners? { |runner| runner.active? && runner.online? && can_be_served?(runner) }
|
||||
end
|
||||
|
|
|
@ -309,6 +309,18 @@ describe Ci::Build, models: true do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#has_tags?' do
|
||||
context 'when build has tags' do
|
||||
subject { create(:ci_build, tag_list: ['tag']) }
|
||||
it { is_expected.to have_tags }
|
||||
end
|
||||
|
||||
context 'when build does not have tags' do
|
||||
subject { create(:ci_build, tag_list: []) }
|
||||
it { is_expected.to_not have_tags }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#any_runners_online?' do
|
||||
subject { build.any_runners_online? }
|
||||
|
||||
|
|
Loading…
Reference in New Issue