summaryrefslogtreecommitdiff
path: root/spec/models/label_spec.rb
diff options
context:
space:
mode:
authorjubianchi <contact@jubianchi.fr>2014-08-20 12:31:16 +0200
committerjubianchi <contact@jubianchi.fr>2014-08-20 12:31:19 +0200
commit9d5c69019371379d055be8ba963fde78d3e0c7f6 (patch)
tree27c355af7ed6e2e40fdde3f7c888517353ccb817 /spec/models/label_spec.rb
parent7ad93ab250019d7737186a0bf8884faf2db2b625 (diff)
downloadgitlab-ce-9d5c69019371379d055be8ba963fde78d3e0c7f6.tar.gz
Add spec on labels validation
Diffstat (limited to 'spec/models/label_spec.rb')
-rw-r--r--spec/models/label_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/models/label_spec.rb b/spec/models/label_spec.rb
index 5098af84cc3..1d273e59bde 100644
--- a/spec/models/label_spec.rb
+++ b/spec/models/label_spec.rb
@@ -5,4 +5,27 @@ describe Label do
it { label.should be_valid }
it { should belong_to(:project) }
+
+ describe 'Validation' do
+ it 'should validate color code' do
+ build(:label, color: 'G-ITLAB').should_not be_valid
+ build(:label, color: 'AABBCC').should_not be_valid
+ build(:label, color: '#AABBCCEE').should_not be_valid
+ build(:label, color: '#GGHHII').should_not be_valid
+ build(:label, color: '#').should_not be_valid
+ build(:label, color: '').should_not be_valid
+
+ build(:label, color: '#AABBCC').should be_valid
+ end
+
+ it 'should validate title' do
+ build(:label, title: 'G,ITLAB').should_not be_valid
+ build(:label, title: 'G?ITLAB').should_not be_valid
+ build(:label, title: 'G&ITLAB').should_not be_valid
+ build(:label, title: '').should_not be_valid
+
+ build(:label, title: 'GITLAB').should be_valid
+ build(:label, title: 'gitlab').should be_valid
+ end
+ end
end