2019-05-09 23:10:02 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-30 00:49:07 +08:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe ReportElement, type: :model do
|
2019-05-09 23:10:02 +08:00
|
|
|
let(:report_element) { build :report_element, :with_experiment }
|
|
|
|
let(:report_element_without_element) { build :report_element }
|
|
|
|
|
|
|
|
it 'is not valid without element' do
|
|
|
|
expect(report_element_without_element).not_to be_valid
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is valid' do
|
|
|
|
expect(report_element).to be_valid
|
|
|
|
end
|
|
|
|
|
2017-08-30 00:49:07 +08:00
|
|
|
it 'should be of class ReportElement' do
|
|
|
|
expect(subject.class).to eq ReportElement
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'Database table' do
|
|
|
|
it { should have_db_column :position }
|
|
|
|
it { should have_db_column :type_of }
|
|
|
|
it { should have_db_column :sort_order }
|
|
|
|
it { should have_db_column :report_id }
|
|
|
|
it { should have_db_column :parent_id }
|
|
|
|
it { should have_db_column :project_id }
|
|
|
|
it { should have_db_column :my_module_id }
|
|
|
|
it { should have_db_column :step_id }
|
|
|
|
it { should have_db_column :result_id }
|
|
|
|
it { should have_db_column :checklist_id }
|
|
|
|
it { should have_db_column :asset_id }
|
|
|
|
it { should have_db_column :table_id }
|
|
|
|
it { should have_db_column :created_at }
|
|
|
|
it { should have_db_column :updated_at }
|
|
|
|
it { should have_db_column :experiment_id }
|
|
|
|
it { should have_db_column :repository_id }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'Relations' do
|
2019-07-26 18:40:36 +08:00
|
|
|
it { should belong_to(:project).optional }
|
|
|
|
it { should belong_to(:experiment).optional }
|
|
|
|
it { should belong_to(:my_module).optional }
|
|
|
|
it { should belong_to(:step).optional }
|
|
|
|
it { should belong_to(:result).optional }
|
|
|
|
it { should belong_to(:checklist).optional }
|
|
|
|
it { should belong_to(:asset).optional }
|
|
|
|
it { should belong_to(:table).optional }
|
|
|
|
it { should belong_to(:repository).optional }
|
2017-08-30 00:49:07 +08:00
|
|
|
it { should belong_to(:report) }
|
|
|
|
it { should have_many(:children).class_name('ReportElement') }
|
|
|
|
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 :position }
|
|
|
|
it { should validate_presence_of :report }
|
|
|
|
it { should validate_presence_of :type_of }
|
|
|
|
end
|
|
|
|
end
|