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
Boxiang Sun
gitlab-ce
Commits
6524ec5d
Commit
6524ec5d
authored
Jan 09, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'label-length-validation' into 'master'
Validate label's title length See merge request !5767
parents
83fd7ea5
7808c9cb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
0 deletions
+7
-0
app/models/label.rb
app/models/label.rb
+1
-0
changelogs/unreleased/validate-title-length.yml
changelogs/unreleased/validate-title-length.yml
+4
-0
spec/models/label_spec.rb
spec/models/label_spec.rb
+2
-0
No files found.
app/models/label.rb
View file @
6524ec5d
...
...
@@ -26,6 +26,7 @@ class Label < ActiveRecord::Base
# Don't allow ',' for label titles
validates
:title
,
presence:
true
,
format:
{
with:
/\A[^,]+\z/
}
validates
:title
,
uniqueness:
{
scope:
[
:group_id
,
:project_id
]
}
validates
:title
,
length:
{
maximum:
255
}
default_scope
{
order
(
title: :asc
)
}
...
...
changelogs/unreleased/validate-title-length.yml
0 → 100644
View file @
6524ec5d
---
title
:
"
Validate
label's
title
length"
merge_request
:
5767
author
:
Tomáš Kukrál
spec/models/label_spec.rb
View file @
6524ec5d
...
...
@@ -31,12 +31,14 @@ describe Label, models: true do
it
'validates title'
do
is_expected
.
not_to
allow_value
(
'G,ITLAB'
).
for
(
:title
)
is_expected
.
not_to
allow_value
(
''
).
for
(
:title
)
is_expected
.
not_to
allow_value
(
's'
*
256
).
for
(
:title
)
is_expected
.
to
allow_value
(
'GITLAB'
).
for
(
:title
)
is_expected
.
to
allow_value
(
'gitlab'
).
for
(
:title
)
is_expected
.
to
allow_value
(
'G?ITLAB'
).
for
(
:title
)
is_expected
.
to
allow_value
(
'G&ITLAB'
).
for
(
:title
)
is_expected
.
to
allow_value
(
"customer's request"
).
for
(
:title
)
is_expected
.
to
allow_value
(
's'
*
255
).
for
(
:title
)
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