2014-08-25 05:25:02 -04:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: labels
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# title :string(255)
|
|
|
|
# color :string(255)
|
|
|
|
# project_id :integer
|
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
|
|
|
#
|
|
|
|
|
2014-07-29 10:10:15 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Label do
|
|
|
|
let(:label) { create(:label) }
|
|
|
|
it { label.should be_valid }
|
|
|
|
|
|
|
|
it { should belong_to(:project) }
|
2014-08-20 06:31:16 -04:00
|
|
|
|
|
|
|
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
|
2014-07-29 10:10:15 -04:00
|
|
|
end
|