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
7808c9cb
Commit
7808c9cb
authored
Aug 11, 2016
by
Tomáš Kukrál
Committed by
Tomáš Kukrál
Jan 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
validate length of label.title
+ add test for label.title length validation
parent
8ab94120
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 @
7808c9cb
...
@@ -26,6 +26,7 @@ class Label < ActiveRecord::Base
...
@@ -26,6 +26,7 @@ class Label < ActiveRecord::Base
# Don't allow ',' for label titles
# Don't allow ',' for label titles
validates
:title
,
presence:
true
,
format:
{
with:
/\A[^,]+\z/
}
validates
:title
,
presence:
true
,
format:
{
with:
/\A[^,]+\z/
}
validates
:title
,
uniqueness:
{
scope:
[
:group_id
,
:project_id
]
}
validates
:title
,
uniqueness:
{
scope:
[
:group_id
,
:project_id
]
}
validates
:title
,
length:
{
maximum:
255
}
default_scope
{
order
(
title: :asc
)
}
default_scope
{
order
(
title: :asc
)
}
...
...
changelogs/unreleased/validate-title-length.yml
0 → 100644
View file @
7808c9cb
---
title
:
"
Validate
label's
title
length"
merge_request
:
5767
author
:
Tomáš Kukrál
spec/models/label_spec.rb
View file @
7808c9cb
...
@@ -31,12 +31,14 @@ describe Label, models: true do
...
@@ -31,12 +31,14 @@ describe Label, models: true do
it
'validates title'
do
it
'validates title'
do
is_expected
.
not_to
allow_value
(
'G,ITLAB'
).
for
(
:title
)
is_expected
.
not_to
allow_value
(
'G,ITLAB'
).
for
(
:title
)
is_expected
.
not_to
allow_value
(
''
).
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
(
'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
(
'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
(
"customer's request"
).
for
(
:title
)
is_expected
.
to
allow_value
(
's'
*
255
).
for
(
:title
)
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