Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomáš Kukrál <kukratom@fit.cvut.cz>2016-08-11 10:37:09 +0300
committerTomáš Kukrál <tom@6shore.net>2017-01-09 14:16:36 +0300
commit7808c9cb50f9706cc2ff4f75abe9531ce683f50a (patch)
tree6aefede1e2d312dfb36802474abddce1d141789c
parent8ab94120ee0a87c7b1158ebafea101e3952ec758 (diff)
validate length of label.title
+ add test for label.title length validation
-rw-r--r--app/models/label.rb1
-rw-r--r--changelogs/unreleased/validate-title-length.yml4
-rw-r--r--spec/models/label_spec.rb2
3 files changed, 7 insertions, 0 deletions
diff --git a/app/models/label.rb b/app/models/label.rb
index 5c01c15e5af..5b6b9a7a736 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -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) }
diff --git a/changelogs/unreleased/validate-title-length.yml b/changelogs/unreleased/validate-title-length.yml
new file mode 100644
index 00000000000..7abf1c4d05a
--- /dev/null
+++ b/changelogs/unreleased/validate-title-length.yml
@@ -0,0 +1,4 @@
+---
+title: "Validate label's title length"
+merge_request: 5767
+author: Tomáš Kukrál
diff --git a/spec/models/label_spec.rb b/spec/models/label_spec.rb
index 0c163659a71..a9139f7d4ab 100644
--- a/spec/models/label_spec.rb
+++ b/spec/models/label_spec.rb
@@ -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