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:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-09-21 23:47:58 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-10-19 19:58:24 +0300
commite28058c4107ce454a84b3e3b5750f936dace7db1 (patch)
tree8eb12341289e76b94907a12067ad8dc85b07f71e /app/models/label.rb
parentcfedd42badc6b84457d1de35cb31988777462d5a (diff)
Validate if project label title does not exist at group level
Diffstat (limited to 'app/models/label.rb')
-rw-r--r--app/models/label.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/app/models/label.rb b/app/models/label.rb
index 0a68be7a30f..f844a3d3378 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -24,13 +24,14 @@ class Label < ActiveRecord::Base
# Don't allow ',' for label titles
validates :title, presence: true, format: { with: /\A[^,]+\z/ }
- validates :title, uniqueness: true, unless: :template?
+ validates :title, uniqueness: { scope: [:group_id, :project_id] }
before_save :nullify_priority
default_scope { order(title: :asc) }
- scope :templates, -> { where(template: true) }
+ scope :templates, -> { where(template: true) }
+ scope :with_title, ->(title) { where(title: title) }
def self.prioritized
where.not(priority: nil).reorder(:priority, :title)