scinote-web/spec/models/asset_spec.rb

59 lines
1.8 KiB
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 Asset, type: :model do
2019-05-06 20:12:45 +08:00
let(:asset) { build :asset }
2017-08-30 00:49:07 +08:00
it 'should be of class Asset' do
expect(subject.class).to eq Asset
end
2019-05-06 20:12:45 +08:00
it 'is valid' do
expect(asset).to be_valid
end
2017-08-30 00:49:07 +08:00
describe 'Database table' do
it { should have_db_column :id }
it { should have_db_column :created_at }
it { should have_db_column :updated_at }
it { should have_db_column :file_file_name }
it { should have_db_column :file_content_type }
it { should have_db_column :file_file_size }
it { should have_db_column :file_updated_at }
it { should have_db_column :created_by_id }
it { should have_db_column :last_modified_by_id }
it { should have_db_column :estimated_size }
it { should have_db_column :file_present }
it { should have_db_column :lock }
it { should have_db_column :lock_ttl }
it { should have_db_column :version }
it { should have_db_column :file_processing }
it { should have_db_column :team_id }
end
describe 'Relations' do
it { should belong_to(:created_by).class_name('User') }
it { should belong_to(:last_modified_by).class_name('User') }
it { should belong_to :team }
it { should have_many :report_elements }
it { should have_one :step_asset }
it { should have_one :step }
it { should have_one :result_asset }
it { should have_one :result }
it { should have_one :asset_text_datum }
2018-03-10 00:04:54 +08:00
it { should have_one :repository_asset_value }
it { should have_one :repository_cell }
2017-08-30 00:49:07 +08:00
end
2019-05-06 20:12:45 +08:00
describe 'Validations' do
describe '#file' do
it { is_expected.to validate_presence_of(:file) }
end
describe '#estimated_size' do
it { expect(asset).to validate_presence_of(:estimated_size) }
2017-08-30 00:49:07 +08:00
end
end
end