Skip to content
Snippets Groups Projects
Commit 84c14ac0 authored by Kamil Trzcińśki's avatar Kamil Trzcińśki
Browse files

Improve validation message and add changelog

parent 48db60e4
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
---
title: Fix validation of environment scope of variables
merge_request:
author:
type: fixed
Loading
Loading
@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment