Do not raise when validating variables expression

This commit is contained in:
Grzegorz Bizon 2018-03-27 14:46:58 +02:00
parent a745eadffb
commit 937630bb8e
3 changed files with 10 additions and 6 deletions

View file

@ -47,7 +47,7 @@ module Gitlab
statements.each do |statement|
unless statement.valid?
errors.add(:variables, "Invalid expression #{statement.inspect}")
errors.add(:variables, "Invalid expression syntax")
end
end
end

View file

@ -37,10 +37,6 @@ module Gitlab
evaluate.present?
end
def inspect
"syntax: #{@lexer.lexemes.join(' ')}"
end
def valid?
parse_tree.is_a?(Lexeme::Base)
rescue StatementError

View file

@ -104,7 +104,15 @@ describe Gitlab::Ci::Config::Entry::Policy do
let(:config) { { variables: ['$MY_VAR =='] } }
it 'reports an error about invalid statement' do
expect(entry.errors).to include /invalid expression syntax: variable equals/
expect(entry.errors).to include /invalid expression syntax/
end
end
context 'when specifying invalid variables expressions token' do
let(:config) { { variables: ['$MY_VAR == 123'] } }
it 'reports an error about invalid statement' do
expect(entry.errors).to include /invalid expression syntax/
end
end