diff --git a/app/models/contact.rb b/app/models/contact.rb index 99139e898..995fdc2a9 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -589,4 +589,9 @@ class Contact < ActiveRecord::Base return if priv? ident end + + def id_code + return unless priv? + ident + end end diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index df4d8cfd3..4d49bc1e8 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -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