mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
parent
16ebdc6c90
commit
e6069e06a9
3 changed files with 33 additions and 0 deletions
|
@ -15,6 +15,7 @@ class Contact < ActiveRecord::Base
|
||||||
has_paper_trail class_name: "ContactVersion", meta: { children: :children_log }
|
has_paper_trail class_name: "ContactVersion", meta: { children: :children_log }
|
||||||
|
|
||||||
attr_accessor :legal_document_id
|
attr_accessor :legal_document_id
|
||||||
|
alias_attribute :kind, :ident_type
|
||||||
|
|
||||||
accepts_nested_attributes_for :legal_documents
|
accepts_nested_attributes_for :legal_documents
|
||||||
|
|
||||||
|
@ -583,4 +584,9 @@ class Contact < ActiveRecord::Base
|
||||||
self[attr_name.to_sym] = nil
|
self[attr_name.to_sym] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reg_no
|
||||||
|
return if priv?
|
||||||
|
ident
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,5 +12,14 @@ FactoryGirl.define do
|
||||||
ident_type 'priv'
|
ident_type 'priv'
|
||||||
ident_country_code 'EE'
|
ident_country_code 'EE'
|
||||||
registrar
|
registrar
|
||||||
|
|
||||||
|
factory :contact_private_entity do
|
||||||
|
ident_type 'priv'
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :contact_legal_entity do
|
||||||
|
ident_type 'org'
|
||||||
|
ident '12345678' # valid reg no for .ee
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -361,6 +361,8 @@ describe Contact, '.destroy_orphans' do
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.describe Contact, db: false do
|
RSpec.describe Contact, db: false do
|
||||||
|
it { is_expected.to alias_attribute(:kind, :ident_type) }
|
||||||
|
|
||||||
describe '::names' do
|
describe '::names' do
|
||||||
before :example do
|
before :example do
|
||||||
expect(described_class).to receive(:pluck).with(:name).and_return('names')
|
expect(described_class).to receive(:pluck).with(:name).and_return('names')
|
||||||
|
@ -463,4 +465,20 @@ RSpec.describe Contact, db: false do
|
||||||
expect(address_removed).to be_truthy
|
expect(address_removed).to be_truthy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#reg_no' do
|
||||||
|
subject(:reg_no) { contact.reg_no }
|
||||||
|
|
||||||
|
context 'when contact is legal entity' do
|
||||||
|
let(:contact) { FactoryGirl.build_stubbed(:contact_legal_entity, ident: '1234') }
|
||||||
|
|
||||||
|
specify { expect(reg_no).to eq('1234') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when contact is private entity' do
|
||||||
|
let(:contact) { FactoryGirl.build_stubbed(:contact_private_entity, ident: '1234') }
|
||||||
|
|
||||||
|
specify { expect(reg_no).to be_nil }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue