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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
9463551e
Commit
9463551e
authored
Sep 20, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validates uniqueness of title unless label is a template
parent
bdb7bf4b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
4 deletions
+3
-4
app/models/label.rb
app/models/label.rb
+2
-4
spec/models/label_spec.rb
spec/models/label_spec.rb
+1
-0
No files found.
app/models/label.rb
View file @
9463551e
...
...
@@ -26,10 +26,8 @@ class Label < ActiveRecord::Base
validates
:project
,
presence:
true
,
if: :project_label?
# Don't allow ',' for label titles
validates
:title
,
presence:
true
,
format:
{
with:
/\A[^,]+\z/
},
uniqueness:
{
scope: :project_id
}
validates
:title
,
presence:
true
,
format:
{
with:
/\A[^,]+\z/
}
validates
:title
,
uniqueness:
true
,
unless: :template?
before_save
:nullify_priority
...
...
spec/models/label_spec.rb
View file @
9463551e
...
...
@@ -19,6 +19,7 @@ describe Label, models: true do
describe
'validation'
do
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:title
)
}
it
'validates color code'
do
expect
(
label
).
not_to
allow_value
(
'G-ITLAB'
).
for
(
:color
)
...
...
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