Skip to content
Snippets Groups Projects
Commit 8001eed0 authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Add method that check if build has tags

parent 82523331
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment