gitlab-org--gitlab-foss/spec/models/label_spec.rb

44 lines
1.3 KiB
Ruby
Raw Normal View History

# == 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
#
require 'spec_helper'
describe Label do
let(:label) { create(:label) }
it { expect(label).to be_valid }
it { is_expected.to belong_to(:project) }
2014-08-20 06:31:16 -04:00
describe 'Validation' do
it 'should validate color code' do
expect(build(:label, color: 'G-ITLAB')).not_to be_valid
expect(build(:label, color: 'AABBCC')).not_to be_valid
expect(build(:label, color: '#AABBCCEE')).not_to be_valid
expect(build(:label, color: '#GGHHII')).not_to be_valid
expect(build(:label, color: '#')).not_to be_valid
expect(build(:label, color: '')).not_to be_valid
2014-08-20 06:31:16 -04:00
expect(build(:label, color: '#AABBCC')).to be_valid
2014-08-20 06:31:16 -04:00
end
it 'should validate title' do
expect(build(:label, title: 'G,ITLAB')).not_to be_valid
expect(build(:label, title: 'G?ITLAB')).not_to be_valid
expect(build(:label, title: 'G&ITLAB')).not_to be_valid
expect(build(:label, title: '')).not_to be_valid
2014-08-20 06:31:16 -04:00
expect(build(:label, title: 'GITLAB')).to be_valid
expect(build(:label, title: 'gitlab')).to be_valid
2014-08-20 06:31:16 -04:00
end
end
end