diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-05-07 20:36:03 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-05-19 22:01:53 +0200 |
commit | f6dd8a5257bf71f87ea9a2fa2f3d16012e61b6e4 (patch) | |
tree | d2e6a5d6cf9e7cfee629c86691ddc66a740145fe /app/models | |
parent | 8ab4a67ca6a9166168b744bc940da98bf9651efd (diff) | |
download | gitlab-ce-f6dd8a5257bf71f87ea9a2fa2f3d16012e61b6e4.tar.gz |
Move runner validator to separate private method
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/runner.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index f5813589492..cf4d3236519 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -26,12 +26,7 @@ module Ci .where("ci_runner_projects.gl_project_id = :project_id OR ci_runners.is_shared = true", project_id: project_id) end - validate do |runner| - unless runner.has_tags? || runner.run_untagged? - errors.add(:tags_list, - 'can not be empty when runner is not allowed to pick untagged jobs') - end - end + validate :verify_tags_constraints acts_as_taggable @@ -107,5 +102,14 @@ module Ci def has_tags? tag_list.any? end + + private + + def verify_tags_constraints + unless has_tags? || run_untagged? + errors.add(:tags_list, + 'can not be empty when runner is not allowed to pick untagged jobs') + end + end end end |