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:
-rw-r--r--app/models/label.rb6
-rw-r--r--features/project/issues/labels.feature5
-rw-r--r--features/steps/project/labels.rb12
3 files changed, 21 insertions, 2 deletions
diff --git a/app/models/label.rb b/app/models/label.rb
index ce982579675..e2379bb6d77 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -3,10 +3,12 @@ class Label < ActiveRecord::Base
has_many :label_links, dependent: :destroy
has_many :issues, through: :label_links, source: :target, source_type: 'Issue'
- validates :color, format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ }, allow_blank: true
+ validates :color,
+ format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ },
+ allow_blank: false
validates :project, presence: true
- # Dont allow '?', '&', and ',' for label titles
+ # Don't allow '?', '&', and ',' for label titles
validates :title, presence: true, format: { with: /\A[^&\?,&]*\z/ }
scope :order_by_name, -> { reorder("labels.title ASC") }
diff --git a/features/project/issues/labels.feature b/features/project/issues/labels.feature
index 4a37b6dc9fa..b88108af719 100644
--- a/features/project/issues/labels.feature
+++ b/features/project/issues/labels.feature
@@ -23,3 +23,8 @@ Feature: Project Labels
Scenario: I remove label
When I remove label 'bug'
Then I should not see label 'bug'
+
+ Scenario: I create a label with invalid color
+ Given I visit new label page
+ When I submit new label with invalid color
+ Then I should see label color error message
diff --git a/features/steps/project/labels.rb b/features/steps/project/labels.rb
index 3d9aa29299c..12ce23da832 100644
--- a/features/steps/project/labels.rb
+++ b/features/steps/project/labels.rb
@@ -31,6 +31,18 @@ class ProjectLabels < Spinach::FeatureSteps
click_button 'Save'
end
+ step 'I submit new label with invalid color' do
+ fill_in 'Title', with: 'support'
+ fill_in 'Background Color', with: '#12'
+ click_button 'Save'
+ end
+
+ step 'I should see label color error message' do
+ within '.label-form' do
+ page.should have_content 'Color is invalid'
+ end
+ end
+
step 'I should not see label \'bug\'' do
within '.manage-labels-list' do
page.should_not have_content 'bug'