Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
48db60e4
Commit
48db60e4
authored
Feb 14, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor variable duplicates error message
parent
9a5ba5c6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
app/validators/variable_duplicates_validator.rb
app/validators/variable_duplicates_validator.rb
+1
-1
No files found.
app/validators/variable_duplicates_validator.rb
View file @
48db60e4
...
@@ -21,7 +21,7 @@ class VariableDuplicatesValidator < ActiveModel::EachValidator
...
@@ -21,7 +21,7 @@ class VariableDuplicatesValidator < ActiveModel::EachValidator
duplicates
=
values
.
reject
(
&
:marked_for_destruction?
).
group_by
(
&
:key
).
select
{
|
_
,
v
|
v
.
many?
}.
map
(
&
:first
)
duplicates
=
values
.
reject
(
&
:marked_for_destruction?
).
group_by
(
&
:key
).
select
{
|
_
,
v
|
v
.
many?
}.
map
(
&
:first
)
if
duplicates
.
any?
if
duplicates
.
any?
error_message
=
"has duplicate variables (
#{
duplicates
.
join
(
", "
)
}
)"
error_message
=
"has duplicate variables (
#{
duplicates
.
join
(
", "
)
}
)"
error_message
+=
"
in
#{
options
[
:scope
]
}
scope"
if
options
[
:scope
]
error_message
+=
"
for
#{
values
.
first
.
send
(
options
[
:scope
])
}
scope"
if
options
[
:scope
]
# rubocop:disable GitlabSecurity/PublicSend
record
.
errors
.
add
(
attribute
,
error_message
)
record
.
errors
.
add
(
attribute
,
error_message
)
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment