Commit 937630bb authored by Grzegorz Bizon's avatar Grzegorz Bizon

Do not raise when validating variables expression

parent a745eadf
......@@ -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
......
......@@ -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
......
......@@ -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
......
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