Commit 6aa5d984 authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Merge branch 'include-ci-yaml' into 'master'

Fixing single string values in the 'include:' keyword of gitlab-ci.yml validations

See merge request gitlab-org/gitlab-ce!26998
title: Fix single string values for the 'include' keyword validation of gitlab-ci.yml.
merge_request: 26998
author: Paul Bonaud (@paulrbr)
type: fixed
......@@ -11,7 +11,7 @@ class Includes < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable
validations do
validates :config, type: Array
validates :config, array_or_string: true
def self.aspects
......@@ -54,6 +54,14 @@ def validate_each(record, attribute, value)
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')
class BooleanValidator < ActiveModel::EachValidator
include LegacyValidationHelpers
......@@ -615,6 +615,14 @@ module Ci
subject {, opts) }
context "when validating a ci config file with no project context" do
context "when a single string is provided" do
let(:include_content) { "/local.gitlab-ci.yml" }
it "does not return any error" do
expect { subject }.not_to raise_error
context "when an array is provided" do
let(:include_content) { ["/local.gitlab-ci.yml"] }
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