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) }
|
2015-02-12 13:17:35 -05:00
|
|
|
it { expect(label).to be_valid }
|
2014-07-29 10:10:15 -04:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to belong_to(:project) }
|
2014-08-20 06:31:16 -04:00
|
|
|
|
|
|
|
describe 'Validation' do
|
|
|
|
it 'should validate color code' do
|
2015-02-12 13:17:35 -05:00
|
|
|
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
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(build(:label, color: '#AABBCC')).to be_valid
|
2014-08-20 06:31:16 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should validate title' do
|
2015-02-12 13:17:35 -05:00
|
|
|
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
|
|
|
|
2015-02-12 13:17:35 -05: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
|
2014-07-29 10:10:15 -04:00
|
|
|
end
|