2019-05-09 23:10:02 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Connection, type: :model do
|
2023-11-13 16:34:38 +08:00
|
|
|
before do
|
|
|
|
allow_any_instance_of(Connection).to receive(:ensure_non_cyclical)
|
|
|
|
end
|
|
|
|
|
2019-05-09 23:10:02 +08:00
|
|
|
let(:connection) { build :connection }
|
|
|
|
|
|
|
|
it 'is valid' do
|
|
|
|
expect(connection).to be_valid
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should be of class Connection' do
|
|
|
|
expect(subject.class).to eq Connection
|
|
|
|
end
|
|
|
|
|
2023-10-12 22:16:43 +08:00
|
|
|
describe 'Database table' do
|
|
|
|
it { should have_db_column :id }
|
|
|
|
it { should have_db_column :input_id }
|
|
|
|
it { should have_db_column :output_id }
|
|
|
|
end
|
|
|
|
|
2019-05-09 23:10:02 +08:00
|
|
|
describe 'Relations' do
|
2023-10-12 22:16:43 +08:00
|
|
|
it { should belong_to(:to).class_name('MyModule').with_foreign_key('input_id').inverse_of(:inputs) }
|
|
|
|
it { should belong_to(:from).class_name('MyModule').with_foreign_key('output_id').inverse_of(:outputs) }
|
2019-05-09 23:10:02 +08:00
|
|
|
end
|
|
|
|
end
|