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
path: root/app
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2014-08-14 12:17:52 +0400
committerRobert Schilling <rschilling@student.tugraz.at>2014-08-14 12:17:52 +0400
commitcbc90565b55d89704d64bc48db323b82b739a873 (patch)
treef6bb4220068bafab7a1b1a57d2b13631a553c4a2 /app
parent04ad197bcc41a26da2c2a80c5b4ffbfad2c296ee (diff)
Do label validation for issues/merge requests API
Diffstat (limited to 'app')
-rw-r--r--app/models/concerns/issuable.rb3
-rw-r--r--app/models/label.rb2
2 files changed, 4 insertions, 1 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 517e4548624..0a5fe24b5af 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -140,7 +140,8 @@ module Issuable
def add_labels_by_names(label_names)
label_names.each do |label_name|
- label = project.labels.find_or_create_by(title: label_name.strip)
+ label = project.labels.create_with(
+ color: Label::DEFAULT_COLOR).find_or_create_by(title: label_name.strip)
self.labels << label
end
end
diff --git a/app/models/label.rb b/app/models/label.rb
index 515ed447f00..a511b7940ed 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -1,4 +1,6 @@
class Label < ActiveRecord::Base
+ DEFAULT_COLOR = '#82C5FF'
+
belongs_to :project
has_many :label_links, dependent: :destroy
has_many :issues, through: :label_links, source: :target, source_type: 'Issue'