Commit 8001eed0 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add method that check if build has tags

parent 82523331
......@@ -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? }
......
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