diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-07-19 20:45:19 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-07-19 20:45:19 +0900 |
commit | 55bc71a404d8cf5fa87e187f6e88da92ab95afa9 (patch) | |
tree | 4b01acfcc771803025ca06bb685c27bc103e8998 | |
parent | 8a576b18c8ab8ead2344e2885aaf2fde11af0328 (diff) | |
download | gitlab-ce-55bc71a404d8cf5fa87e187f6e88da92ab95afa9.tar.gz |
Use array_of_strings_or_string in Command
-rw-r--r-- | lib/gitlab/ci/config/entry/commands.rb | 13 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/commands_spec.rb | 3 |
2 files changed, 2 insertions, 14 deletions
diff --git a/lib/gitlab/ci/config/entry/commands.rb b/lib/gitlab/ci/config/entry/commands.rb index 65d19db249c..9f66f11be9b 100644 --- a/lib/gitlab/ci/config/entry/commands.rb +++ b/lib/gitlab/ci/config/entry/commands.rb @@ -9,18 +9,7 @@ module Gitlab include Validatable validations do - include LegacyValidationHelpers - - validate do - unless string_or_array_of_strings?(config) - errors.add(:config, - 'should be a string or an array of strings') - end - end - - def string_or_array_of_strings?(field) - validate_string(field) || validate_array_of_strings(field) - end + validates :config, array_of_strings_or_string: true end def value diff --git a/spec/lib/gitlab/ci/config/entry/commands_spec.rb b/spec/lib/gitlab/ci/config/entry/commands_spec.rb index afa4a089418..84734b06caa 100644 --- a/spec/lib/gitlab/ci/config/entry/commands_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/commands_spec.rb @@ -41,8 +41,7 @@ describe Gitlab::Ci::Config::Entry::Commands do describe '#errors' do it 'saves errors' do expect(entry.errors) - .to include 'commands config should be a ' \ - 'string or an array of strings' + .to include 'commands config should be an array of strings or string' end end end |