Commit a3c969cd authored by Robert Schilling's avatar Robert Schilling

Add testcase for invalid color

parent 6085b6a7
...@@ -3,10 +3,12 @@ class Label < ActiveRecord::Base ...@@ -3,10 +3,12 @@ class Label < ActiveRecord::Base
has_many :label_links, dependent: :destroy has_many :label_links, dependent: :destroy
has_many :issues, through: :label_links, source: :target, source_type: 'Issue' 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 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/ } validates :title, presence: true, format: { with: /\A[^&\?,&]*\z/ }
scope :order_by_name, -> { reorder("labels.title ASC") } scope :order_by_name, -> { reorder("labels.title ASC") }
......
...@@ -23,3 +23,8 @@ Feature: Project Labels ...@@ -23,3 +23,8 @@ Feature: Project Labels
Scenario: I remove label Scenario: I remove label
When I remove label 'bug' When I remove label 'bug'
Then I should not see 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
...@@ -31,6 +31,18 @@ class ProjectLabels < Spinach::FeatureSteps ...@@ -31,6 +31,18 @@ class ProjectLabels < Spinach::FeatureSteps
click_button 'Save' click_button 'Save'
end 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 step 'I should not see label \'bug\'' do
within '.manage-labels-list' do within '.manage-labels-list' do
page.should_not have_content 'bug' page.should_not have_content 'bug'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment