Commit ec3b5087 authored by Matija Čupić's avatar Matija Čupić

Refactor validation error messages

parent c1cb7907
......@@ -38,10 +38,9 @@ module EE
validate on: :composed do
next unless bridge_needs.present?
next if bridge_needs.one?
unless bridge_needs.one?
errors.add(:config, 'should contain exactly one bridge need')
end
errors.add(:config, 'should contain at most one bridge need')
end
end
......
......@@ -199,7 +199,7 @@ describe EE::Gitlab::Ci::Config::Entry::Bridge do
describe '#errors' do
it 'returns an error about too many bridge needs' do
expect(subject.errors).to contain_exactly('bridge config should contain exactly one bridge need')
expect(subject.errors).to contain_exactly('bridge config should contain at most one bridge need')
end
end
end
......
......@@ -23,7 +23,7 @@ describe Gitlab::Ci::Config::Entry::Job do
it 'returns error about invalid needs type' do
expect(entry).not_to be_valid
expect(entry.errors).to contain_exactly('needs config uses bridge type(s)')
expect(entry.errors).to contain_exactly('needs config uses invalid types: bridge')
end
end
end
......
......@@ -22,7 +22,7 @@ module Gitlab
validate on: :composed do
extra_keys = value.keys - opt(:allowed_needs)
if extra_keys.any?
errors.add(:config, "uses #{extra_keys.join(', ')} type(s)")
errors.add(:config, "uses invalid types: #{extra_keys.join(', ')}")
end
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