Skip to content
代码片段 群组 项目
提交 a3c969cd 编辑于 作者: Robert Schilling's avatar Robert Schilling
浏览文件

Add testcase for invalid color

上级 6085b6a7
No related branches found
No related tags found
无相关合并请求
......@@ -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") }
......
......@@ -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
......@@ -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'
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册