Return contact's id code if it is private entity

#268
This commit is contained in:
Artur Beljajev 2017-01-18 11:46:12 +02:00
parent 0042fc2d5a
commit e08afe0983
2 changed files with 19 additions and 0 deletions

View file

@ -589,4 +589,9 @@ class Contact < ActiveRecord::Base
return if priv?
ident
end
def id_code
return unless priv?
ident
end
end

View file

@ -481,4 +481,18 @@ RSpec.describe Contact, db: false do
specify { expect(reg_no).to be_nil }
end
end
describe '#id_code' do
context 'when contact is private entity' do
let(:contact) { FactoryGirl.build_stubbed(:contact_private_entity, ident: '1234') }
specify { expect(contact.id_code).to eq('1234') }
end
context 'when contact is legal entity' do
let(:contact) { FactoryGirl.build_stubbed(:contact_legal_entity, ident: '1234') }
specify { expect(contact.id_code).to be_nil }
end
end
end