mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 16:53:37 +02:00
Refactored contact with ability
This commit is contained in:
parent
62f8061e10
commit
96d1c60dd8
33 changed files with 763 additions and 1045 deletions
|
@ -1,91 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe ContactDisclosure do
|
||||
it { should belong_to(:contact) }
|
||||
|
||||
context 'about class' do
|
||||
it 'should have versioning enabled?' do
|
||||
ContactDisclosure.paper_trail_enabled_for_model?.should == true
|
||||
end
|
||||
|
||||
it 'should have custom log prexied table name for versions table' do
|
||||
ContactDisclosureVersion.table_name.should == 'log_contact_disclosures'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid attribute' do
|
||||
before :all do
|
||||
@contact_disclosure = ContactDisclosure.new
|
||||
end
|
||||
|
||||
it 'should not be valid' do
|
||||
@contact_disclosure.valid?
|
||||
@contact_disclosure.errors.full_messages.should match_array([
|
||||
])
|
||||
end
|
||||
|
||||
it 'should not have any versions' do
|
||||
@contact_disclosure.versions.should == []
|
||||
end
|
||||
end
|
||||
|
||||
context 'with valid attributes' do
|
||||
before :all do
|
||||
@contact_disclosure = Fabricate(:contact_disclosure)
|
||||
end
|
||||
|
||||
it 'should be valid' do
|
||||
@contact_disclosure.valid?
|
||||
@contact_disclosure.errors.full_messages.should match_array([])
|
||||
end
|
||||
|
||||
it 'should be valid twice' do
|
||||
@contact_disclosure = Fabricate(:contact_disclosure)
|
||||
@contact_disclosure.valid?
|
||||
@contact_disclosure.errors.full_messages.should match_array([])
|
||||
end
|
||||
|
||||
it 'should have one version' do
|
||||
with_versioning do
|
||||
@contact_disclosure.versions.should == []
|
||||
@contact_disclosure.name = false
|
||||
@contact_disclosure.save
|
||||
@contact_disclosure.errors.full_messages.should match_array([])
|
||||
@contact_disclosure.versions.size.should == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe '.extract_attributes' do
|
||||
it 'should return empty hash for empty arguments' do
|
||||
result = ContactDisclosure.extract_attributes(Nokogiri::XML::Document.new)
|
||||
expect(result).to eq({})
|
||||
end
|
||||
|
||||
it 'should return empty hash if no disclosure' do
|
||||
parsed_frame = Nokogiri::XML(create_contact_xml).remove_namespaces!
|
||||
result = ContactDisclosure.extract_attributes(parsed_frame)
|
||||
expect(result).to eq({})
|
||||
end
|
||||
|
||||
# TODO: remodel create contact xml to support disclosure
|
||||
it 'should return disclosure has if disclosure' do
|
||||
epp_xml = EppXml::Contact.new
|
||||
xml = epp_xml.create(
|
||||
{
|
||||
disclose: { value: {
|
||||
voice: { value: '' },
|
||||
addr: { value: '' },
|
||||
name: { value: '' },
|
||||
org_name: { value: '' },
|
||||
email: { value: '' },
|
||||
fax: { value: '' }
|
||||
}, attrs: { flag: '0' }
|
||||
} })
|
||||
parsed_frame = Nokogiri::XML(xml).remove_namespaces!
|
||||
result = ContactDisclosure.extract_attributes(parsed_frame)
|
||||
expect(result).to eq({ phone: '0', email: '0', fax: '0', address: '0', name: '0', org_name: '0' })
|
||||
end
|
||||
end
|
|
@ -39,11 +39,11 @@ describe Contact do
|
|||
end
|
||||
|
||||
it 'should not have creator' do
|
||||
@contact.cr_id.should == nil
|
||||
@contact.creator.should == nil
|
||||
end
|
||||
|
||||
it 'should not have updater' do
|
||||
@contact.up_id.should == nil
|
||||
@contact.updator.should == nil
|
||||
end
|
||||
|
||||
it 'phone should return false' do
|
||||
|
@ -179,57 +179,18 @@ describe Contact do
|
|||
end
|
||||
|
||||
context 'with creator' do
|
||||
before :all do
|
||||
# @contact.created_by = @api_user
|
||||
end
|
||||
|
||||
# TODO: change cr_id to something else
|
||||
it 'should return username of creator' do
|
||||
# @contact.cr_id.should == 'gitlab'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with updater' do
|
||||
before :all do
|
||||
# @contact.updated_by = @api_user
|
||||
# @contact.creator_str.should == 'gitlab'
|
||||
end
|
||||
|
||||
# TODO: change up_id to something else
|
||||
it 'should return username of updater' do
|
||||
# @contact.up_id.should == 'gitlab'
|
||||
# @contact.updator.should == 'gitlab'
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: investigate it a bit more
|
||||
# describe Contact, '#relations_with_domain?' do
|
||||
# context 'with relation' do
|
||||
# before :all do
|
||||
# create_settings
|
||||
# Fabricate(:domain)
|
||||
# @contact = Fabricate(:contact)
|
||||
# end
|
||||
|
||||
# it 'should have relation with domain' do
|
||||
# @contact.relations_with_domain?.should == true
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
describe Contact, '.extract_params' do
|
||||
it 'returns params hash'do
|
||||
ph = { id: '123123', email: 'jdoe@example.com', authInfo: { pw: 'asde' },
|
||||
postalInfo: { name: 'fred', addr: { cc: 'EE' } } }
|
||||
Contact.extract_attributes(ph).should == {
|
||||
name: 'fred',
|
||||
email: 'jdoe@example.com'
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
describe Contact, '.check_availability' do
|
||||
before do
|
||||
Fabricate(:contact, code: 'asd12')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue