mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Merge branch 'master' of github.com:internetee/registry
This commit is contained in:
commit
ae40264a2d
3 changed files with 12 additions and 10 deletions
|
@ -1,6 +1,7 @@
|
|||
module Epp::ContactsHelper
|
||||
def create_contact
|
||||
@contact = Contact.new(contact_and_address_attributes)
|
||||
@contact.generate_code
|
||||
render '/epp/contacts/create' and return if stamp(@contact) && @contact.save
|
||||
|
||||
handle_errors(@contact)
|
||||
|
@ -54,7 +55,7 @@ module Epp::ContactsHelper
|
|||
## CREATE
|
||||
def validate_contact_create_request
|
||||
@ph = params_hash['epp']['command']['create']['create']
|
||||
xml_attrs_present?(@ph, [%w(id), %w(authInfo pw), %w(postalInfo)])
|
||||
xml_attrs_present?(@ph, [ %w(authInfo pw), %w(postalInfo)])
|
||||
|
||||
return epp_errors.empty? unless @ph['postalInfo'].is_a?(Hash) || @ph['postalInfo'].is_a?(Array)
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ class Contact < ActiveRecord::Base
|
|||
|
||||
include EppErrors
|
||||
|
||||
has_one :local_address
|
||||
has_one :international_address
|
||||
has_one :local_address, dependent: :destroy
|
||||
has_one :international_address, dependent: :destroy
|
||||
has_one :disclosure, class_name: 'ContactDisclosure'
|
||||
|
||||
has_many :domain_contacts
|
||||
|
@ -78,6 +78,12 @@ class Contact < ActiveRecord::Base
|
|||
auth_info == pw
|
||||
end
|
||||
|
||||
# generate random id for contact
|
||||
#
|
||||
def generate_code
|
||||
self.code = SecureRandom.hex(4)
|
||||
end
|
||||
|
||||
# Find a way to use self.domains with contact
|
||||
def domains_owned
|
||||
Domain.where(owner_contact_id: id)
|
||||
|
@ -90,7 +96,6 @@ class Contact < ActiveRecord::Base
|
|||
|
||||
# should use only in transaction
|
||||
def destroy_and_clean
|
||||
clean_up_address
|
||||
|
||||
if relations_with_domain?
|
||||
errors.add(:domains, :exist)
|
||||
|
@ -153,8 +158,4 @@ class Contact < ActiveRecord::Base
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
def clean_up_address
|
||||
address.destroy if address
|
||||
end
|
||||
end
|
||||
|
|
|
@ -69,13 +69,13 @@ describe 'EPP Contact', epp: true do
|
|||
id = response[:parsed].css('resData creData id').first
|
||||
cr_date = response[:parsed].css('resData creData crDate').first
|
||||
|
||||
expect(id.text).to eq('sh8013')
|
||||
expect(id.text.length).to eq(8)
|
||||
# 5 seconds for what-ever weird lag reasons might happen
|
||||
expect(cr_date.text.to_time).to be_within(5).of(Time.now)
|
||||
|
||||
end
|
||||
|
||||
it 'does not create duplicate contact' do
|
||||
it 'does not create duplicate contact', pending: true do
|
||||
Fabricate(:contact, code: 'sh8013')
|
||||
|
||||
response = epp_request(contact_create_xml, :xml)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue