BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
0 deletions
+7
-0
label.rb
app/models/label.rb
+1
-0
validate-title-length.yml
changelogs/unreleased/validate-title-length.yml
+4
-0
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
# 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 @
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
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