2019-12-06 20:18:35 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2019-12-09 20:38:40 +08:00
|
|
|
RSpec.describe RepositoryChecklistItem, type: :model do
|
|
|
|
let(:repository_checklist_item) { build :repository_checklist_item }
|
2019-12-06 20:18:35 +08:00
|
|
|
|
|
|
|
it 'is valid' do
|
2019-12-09 20:38:40 +08:00
|
|
|
expect(repository_checklist_item).to be_valid
|
2019-12-06 20:18:35 +08:00
|
|
|
end
|
|
|
|
|
2019-12-09 20:38:40 +08:00
|
|
|
it 'should be of class RepositoryChecklistItem' do
|
|
|
|
expect(subject.class).to eq RepositoryChecklistItem
|
2019-12-06 20:18:35 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'Database table' do
|
|
|
|
it { should have_db_column :data }
|
|
|
|
it { should have_db_column :created_by_id }
|
|
|
|
it { should have_db_column :last_modified_by_id }
|
|
|
|
it { should have_db_column :repository_column_id }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'Relations' do
|
|
|
|
it { should belong_to :repository_column }
|
|
|
|
it { should belong_to(:created_by).class_name('User') }
|
|
|
|
it { should belong_to(:last_modified_by).class_name('User') }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'Validations' do
|
|
|
|
describe '#data' do
|
|
|
|
it { is_expected.to validate_presence_of(:data) }
|
2019-12-06 21:16:20 +08:00
|
|
|
it { is_expected.to validate_length_of(:data).is_at_most(Constants::NAME_MAX_LENGTH) }
|
2019-12-06 20:18:35 +08:00
|
|
|
it {
|
2019-12-09 20:38:40 +08:00
|
|
|
expect(repository_checklist_item).to validate_uniqueness_of(:data)
|
2019-12-06 20:18:35 +08:00
|
|
|
.scoped_to(:repository_column_id).case_insensitive
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|