require 'rails_helper' module Logistics module Core RSpec.describe AgencyPermitDocument, type: :model do it 'has a valid factory' do expect(create(:agency_permit_document)).to be_valid end it 'is invalid with no agency' do expect(build(:agency_permit_document, :agency_id => nil)).not_to be_valid end it 'is invalid with no document type' do expect(build(:agency_permit_document, :document_type_id => nil)).not_to be_valid end it 'is invalid with duplicate agency and document type' do lookup = create(:agency_permit_document) expect(build(:agency_permit_document, :agency_id => lookup.agency_id, :document_type_id => lookup.document_type_id)).not_to be_valid end end end end