Add testcase for invalid color
This commit is contained in:
parent
6085b6a765
commit
a3c969cd92
3 changed files with 21 additions and 2 deletions
|
@ -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
|
||||||
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
|
||||||
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'
|
||||||
|
|
Loading…
Reference in a new issue