2019-05-09 23:10:02 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-30 00:49:07 +08:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe ProtocolKeyword, type: :model do
|
2019-05-09 23:10:02 +08:00
|
|
|
let(:protocol_keyword) { build :protocol_keyword }
|
|
|
|
|
|
|
|
it 'is valid' do
|
|
|
|
expect(protocol_keyword).to be_valid
|
|
|
|
end
|
|
|
|
|
2017-08-30 00:49:07 +08:00
|
|
|
it 'should be of class ProtocolKeyword' do
|
|
|
|
expect(subject.class).to eq ProtocolKeyword
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'Database table' do
|
|
|
|
it { should have_db_column :name }
|
|
|
|
it { should have_db_column :created_at }
|
|
|
|
it { should have_db_column :updated_at }
|
|
|
|
it { should have_db_column :nr_of_protocols }
|
|
|
|
it { should have_db_column :team_id }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'Relations' do
|
|
|
|
it { should belong_to :team }
|
|
|
|
it { should have_many :protocol_protocol_keywords }
|
|
|
|
it { should have_many :protocols }
|
|
|
|
end
|
|
|
|
|
2019-05-09 23:10:02 +08:00
|
|
|
describe 'Validations' do
|
2017-08-30 00:49:07 +08:00
|
|
|
it { should validate_presence_of :team }
|
|
|
|
it do
|
|
|
|
should validate_length_of(:name)
|
2019-07-26 18:40:36 +08:00
|
|
|
.is_at_least(Constants::NAME_MIN_LENGTH)
|
|
|
|
.is_at_most(Constants::NAME_MAX_LENGTH)
|
2017-08-30 00:49:07 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|