summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-02-14 22:51:04 +0100
committerKamil Trzciński <ayufan@ayufan.eu>2018-02-14 22:52:20 +0100
commit84c14ac0c2ec4957f5fe4c53be3d068ee2f1743a (patch)
tree8445d80af4e64d780d3b01d897c5b8da76248901
parent48db60e47987a3a7c08856423daf7713eb256e74 (diff)
downloadgitlab-ce-mc/fix/project-variables-scope.tar.gz
Improve validation message and add changelogmc/fix/project-variables-scope
-rw-r--r--app/validators/variable_duplicates_validator.rb2
-rw-r--r--changelogs/unreleased/fix-validation-of-environment-scope-for-variables.yml5
-rw-r--r--spec/support/features/variable_list_shared_examples.rb2
3 files changed, 7 insertions, 2 deletions
diff --git a/app/validators/variable_duplicates_validator.rb b/app/validators/variable_duplicates_validator.rb
index 37e0a476399..4bfa3c45303 100644
--- a/app/validators/variable_duplicates_validator.rb
+++ b/app/validators/variable_duplicates_validator.rb
@@ -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
diff --git a/changelogs/unreleased/fix-validation-of-environment-scope-for-variables.yml b/changelogs/unreleased/fix-validation-of-environment-scope-for-variables.yml
new file mode 100644
index 00000000000..5424c15a8ae
--- /dev/null
+++ b/changelogs/unreleased/fix-validation-of-environment-scope-for-variables.yml
@@ -0,0 +1,5 @@
+---
+title: Fix validation of environment scope of variables
+merge_request:
+author:
+type: fixed
diff --git a/spec/support/features/variable_list_shared_examples.rb b/spec/support/features/variable_list_shared_examples.rb
index b7d896c9409..0d8f7a7aae6 100644
--- a/spec/support/features/variable_list_shared_examples.rb
+++ b/spec/support/features/variable_list_shared_examples.rb
@@ -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