From 9f36097db2a5901312d7ea86c5a0df315311b7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20=F0=9F=90=BB?= Date: Fri, 5 Apr 2019 06:44:33 +0000 Subject: fix(gitlab-ci-config): allow strings in the 'include' keyword This fix is a followup to !24098 which introduced a validation of the `include:` keyword of a gitlab-ci configuration file when triggered from /ci/lint API calls. However, there was a test case missing: the case of a single string as value. I have added a test case for that which shows that the code was not validating it correctly. This commit fixes that to allow all `include:` valid inputs. --- lib/gitlab/config/entry/validators.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/gitlab/config') diff --git a/lib/gitlab/config/entry/validators.rb b/lib/gitlab/config/entry/validators.rb index 746fe83f90f..df34d254c65 100644 --- a/lib/gitlab/config/entry/validators.rb +++ b/lib/gitlab/config/entry/validators.rb @@ -54,6 +54,14 @@ module Gitlab end end + class ArrayOrStringValidator < ActiveModel::EachValidator + def validate_each(record, attribute, value) + unless value.is_a?(Array) || value.is_a?(String) + record.errors.add(attribute, 'should be an array or a string') + end + end + end + class BooleanValidator < ActiveModel::EachValidator include LegacyValidationHelpers -- cgit v1.2.3