Improve validation message and add changelog
This commit is contained in:
parent
48db60e479
commit
84c14ac0c2
|
@ -20,7 +20,7 @@ class VariableDuplicatesValidator < ActiveModel::EachValidator
|
|||
def validate_duplicates(record, attribute, values)
|
||||
duplicates = values.reject(&:marked_for_destruction?).group_by(&:key).select { |_, v| v.many? }.map(&:first)
|
||||
if duplicates.any?
|
||||
error_message = "has duplicate variables (#{duplicates.join(", ")})"
|
||||
error_message = "have duplicate values (#{duplicates.join(", ")})"
|
||||
error_message += " for #{values.first.send(options[:scope])} scope" if options[:scope] # rubocop:disable GitlabSecurity/PublicSend
|
||||
record.errors.add(attribute, error_message)
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix validation of environment scope of variables
|
||||
merge_request:
|
||||
author:
|
||||
type: fixed
|
|
@ -263,7 +263,7 @@ shared_examples 'variable list' do
|
|||
|
||||
# We check the first row because it re-sorts to alphabetical order on refresh
|
||||
page.within('.js-ci-variable-list-section') do
|
||||
expect(find('.js-ci-variable-error-box')).to have_content(/Validation failed Variables has duplicate variables \(.+\)/)
|
||||
expect(find('.js-ci-variable-error-box')).to have_content(/Validation failed Variables have duplicate values \(.+\)/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue