scinote-web/spec/models/asset_text_datum_spec.rb

39 lines
914 B
Ruby
Raw Normal View History

2019-05-06 20:12:45 +08:00
# frozen_string_literal: true
2017-08-30 00:49:07 +08:00
require 'rails_helper'
describe AssetTextDatum, type: :model do
2019-05-06 20:12:45 +08:00
let(:asset_text_datum) { build :asset_text_datum }
it 'is valid' do
expect(asset_text_datum).to be_valid
end
2017-08-30 00:49:07 +08:00
it 'should be of class Activity' do
expect(subject.class).to eq AssetTextDatum
end
describe 'Database table' do
it { should have_db_column :id }
it { should have_db_column :data }
it { should have_db_column :asset_id }
it { should have_db_column :created_at }
it { should have_db_column :data_vector }
end
describe 'Relations' do
it { should belong_to :asset }
end
2019-05-06 20:12:45 +08:00
describe 'Validations' do
describe '#data' do
it { is_expected.to validate_presence_of(:data) }
end
2017-08-30 00:49:07 +08:00
2019-05-06 20:12:45 +08:00
describe '#asset' do
it { is_expected.to validate_presence_of(:asset) }
it { expect(asset_text_datum).to validate_uniqueness_of(:asset) }
2017-08-30 00:49:07 +08:00
end
end
end