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:
authorjubianchi <contact@jubianchi.fr>2014-08-18 00:22:01 +0400
committerjubianchi <contact@jubianchi.fr>2014-08-20 14:09:19 +0400
commit7ad93ab250019d7737186a0bf8884faf2db2b625 (patch)
treecd75991df1a3fe502549dd4f0a1b1d35ba6ddb58 /app
parented9e922dd0047435b8d349f0c949ba0a2d789247 (diff)
Improve labels validation and expose error messages
Diffstat (limited to 'app')
-rw-r--r--app/models/concerns/issuable.rb4
-rw-r--r--app/models/label.rb4
2 files changed, 6 insertions, 2 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 0a5fe24b5af..5c9b44812be 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -138,6 +138,10 @@ module Issuable
labels.order('title ASC').pluck(:title)
end
+ def remove_labels
+ labels.delete_all
+ end
+
def add_labels_by_names(label_names)
label_names.each do |label_name|
label = project.labels.create_with(
diff --git a/app/models/label.rb b/app/models/label.rb
index 3ff52416c24..233f477444f 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -6,14 +6,14 @@ class Label < ActiveRecord::Base
has_many :issues, through: :label_links, source: :target, source_type: 'Issue'
validates :color,
- format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ },
+ format: { with: /\A#[0-9A-Fa-f]{6}\Z/ },
allow_blank: false
validates :project, presence: true
# Don't allow '?', '&', and ',' for label titles
validates :title,
presence: true,
- format: { with: /\A[^&\?,&]*\z/ },
+ format: { with: /\A[^&\?,&]+\z/ },
uniqueness: { scope: :project_id }
scope :order_by_name, -> { reorder("labels.title ASC") }