Sha256: 0c90f9dec20e2f074e27bae31ceaababdfb8153e8760a4d2f18c6e908413306a

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'

describe Creditor do
  it { is_expected.to be_a_kind_of Persona::Creditor }

  it { is_expected.to belong_to :main_cnae }
  it { is_expected.to belong_to :occupation_classification }
  it { is_expected.to belong_to :person }

  it { is_expected.to have_many(:creditor_secondary_cnaes).dependent :destroy }
  it { is_expected.to have_many(:cnaes).through :creditor_secondary_cnaes }
  it { is_expected.to have_many(:representatives).class_name('CreditorRepresentative').dependent :destroy }
  it { is_expected.to have_many(:creditor_balances).dependent :destroy }
  it { is_expected.to have_many(:document_types).through :documents }
  it { is_expected.to have_many(:documents).class_name('CreditorDocument').dependent :destroy }
  it { is_expected.to have_many(:accounts).dependent :destroy }
  it { is_expected.to have_many(:agencies).through :accounts }
  it { is_expected.to have_many(:banks).through :accounts }
  it { is_expected.to have_many(:documents).dependent :destroy }
  it { is_expected.to have_many(:document_types).through :documents }
  it { is_expected.to have_many(:regularization_or_administrative_sanctions).dependent :destroy }
  it { is_expected.to have_many(:registration_cadastral_certificates).dependent :destroy }

  it { is_expected.to validate_presence_of :person }

  context 'validations' do
    describe 'contract_start_date' do
      it 'allows only date formats' do
        expect(subject).to allow_value(Date.new).for :contract_start_date
        expect(subject).to_not allow_value(:foobar).for :contract_start_date
      end

      it 'allows blank value' do
        expect(subject).to allow_value('').for :contract_start_date
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unico-training-7.8.0 spec/models/creditor_spec.rb