Added customer composite key
This commit is contained in:
41
spec/models/company_spec.rb
Normal file
41
spec/models/company_spec.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Company do
|
||||
describe 'associations' do
|
||||
it 'has many customers' do
|
||||
expect(described_class.reflect_on_association(:customers).macro).to eq(:has_many)
|
||||
end
|
||||
|
||||
it 'has many reservations' do
|
||||
expect(described_class.reflect_on_association(:reservations).macro).to eq(:has_many)
|
||||
end
|
||||
|
||||
it 'has many teams' do
|
||||
expect(described_class.reflect_on_association(:teams).macro).to eq(:has_many)
|
||||
end
|
||||
|
||||
it 'destroys dependent customers when deleted' do
|
||||
expect(described_class.reflect_on_association(:customers).options[:dependent]).to eq(:destroy)
|
||||
end
|
||||
|
||||
it 'destroys dependent reservations when deleted' do
|
||||
expect(described_class.reflect_on_association(:reservations).options[:dependent]).to eq(:destroy)
|
||||
end
|
||||
|
||||
it 'destroys dependent teams when deleted' do
|
||||
expect(described_class.reflect_on_association(:teams).options[:dependent]).to eq(:destroy)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'instance methods' do
|
||||
let(:company) { described_class.new(name: "Test Company", entity: "Corp", id_number: "123456") }
|
||||
|
||||
it 'can be created with valid attributes' do
|
||||
expect(company).to be_valid
|
||||
end
|
||||
|
||||
it 'can be saved to the database' do
|
||||
expect { company.save }.to change(described_class, :count).by(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user