diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-08-20 15:09:31 +0200 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-08-20 15:09:31 +0200 |
commit | 39464857651a0f7dc0e4a3ad89e766ea200c36ba (patch) | |
tree | 1d598967c659c4670ecd61674834aa17b4da9168 /app | |
parent | f5b23bc2caa8ece27abe4278f6a1b779442f85b4 (diff) | |
parent | 9d5c69019371379d055be8ba963fde78d3e0c7f6 (diff) | |
download | gitlab-ce-39464857651a0f7dc0e4a3ad89e766ea200c36ba.tar.gz |
Merge pull request #7526 from jubianchi/api/issue-api-validate-labels
API: Labels validation in issues API
Diffstat (limited to 'app')
-rw-r--r-- | app/models/concerns/issuable.rb | 4 | ||||
-rw-r--r-- | app/models/label.rb | 4 |
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") } |