Do not raise when validating variables expression
This commit is contained in:
parent
a745eadffb
commit
937630bb8e
3 changed files with 10 additions and 6 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue