mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 22:54:47 +02:00
Merge pull request #1810 from internetee/1808-transfer-fails-to-create-new-admin-contact-2
Contact test for new registrant after domain transfer
This commit is contained in:
commit
6b4ab2f05c
2 changed files with 96 additions and 2 deletions
|
@ -59,7 +59,7 @@ module Concerns::Domain::Transferable
|
|||
copied_ids = []
|
||||
domain_contacts.each do |dc|
|
||||
contact = Contact.find(dc.contact_id)
|
||||
next if copied_ids.include?(contact.id) || contact.registrar == new_registrar
|
||||
next if copied_ids.include?(uniq_contact_hash(dc)) || contact.registrar == new_registrar
|
||||
|
||||
if registrant_id_was == contact.id # registrant was copied previously, do not copy it again
|
||||
oc = OpenStruct.new(id: registrant_id)
|
||||
|
@ -72,7 +72,11 @@ module Concerns::Domain::Transferable
|
|||
else
|
||||
dc.update(contact_id: oc.id)
|
||||
end
|
||||
copied_ids << contact.id
|
||||
copied_ids << uniq_contact_hash(dc)
|
||||
end
|
||||
end
|
||||
|
||||
def uniq_contact_hash(contact)
|
||||
Digest::SHA1.hexdigest(contact.contact_id.to_s + contact.type)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@ require 'test_helper'
|
|||
class EppDomainTransferRequestTest < EppTestCase
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
@contact = contacts(:jane)
|
||||
@new_registrar = registrars(:goodnames)
|
||||
@original_transfer_wait_time = Setting.transfer_wait_time
|
||||
Setting.transfer_wait_time = 0
|
||||
|
@ -12,6 +13,95 @@ class EppDomainTransferRequestTest < EppTestCase
|
|||
Setting.transfer_wait_time = @original_transfer_wait_time
|
||||
end
|
||||
|
||||
def test_transfer_domain_with_contacts_if_registrant_and_tech_are_shared
|
||||
@domain.tech_domain_contacts[0].update!(contact_id: @domain.registrant.id)
|
||||
|
||||
@domain.tech_domain_contacts[1].delete
|
||||
@domain.reload
|
||||
|
||||
post epp_transfer_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
|
||||
@domain.reload
|
||||
|
||||
tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id)
|
||||
|
||||
assert_equal @domain.contacts.where(original_id: @domain.registrant.original_id).count, 1
|
||||
assert_equal tech.registrar_id, @domain.registrar.id
|
||||
end
|
||||
|
||||
def test_transfer_domain_with_contacts_if_registrant_and_admin_are_shared
|
||||
@domain.admin_domain_contacts[0].update!(contact_id: @domain.registrant.id)
|
||||
@domain.tech_domain_contacts[0].update!(contact_id: @contact.id)
|
||||
|
||||
@domain.tech_domain_contacts[1].delete
|
||||
@domain.reload
|
||||
|
||||
post epp_transfer_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
|
||||
@domain.reload
|
||||
|
||||
admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id)
|
||||
|
||||
assert_equal @domain.contacts.where(original_id: @domain.registrant.original_id).count, 1
|
||||
assert_equal admin.registrar_id, @domain.registrar.id
|
||||
end
|
||||
|
||||
def test_transfer_domain_with_contacts_if_admin_and_tech_are_shared
|
||||
@domain.admin_domain_contacts[0].update!(contact_id: @contact.id)
|
||||
@domain.tech_domain_contacts[0].update!(contact_id: @contact.id)
|
||||
|
||||
@domain.tech_domain_contacts[1].delete
|
||||
@domain.reload
|
||||
|
||||
post epp_transfer_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
|
||||
@domain.reload
|
||||
|
||||
admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id)
|
||||
tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id)
|
||||
|
||||
result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count)
|
||||
assert result_hash[admin.original_id], 2
|
||||
|
||||
assert_equal admin.registrar_id, @domain.registrar.id
|
||||
assert_equal tech.registrar_id, @domain.registrar.id
|
||||
end
|
||||
|
||||
def test_transfer_domain_with_contacts_if_admin_and_tech_and_registrant_are_shared
|
||||
@domain.tech_domain_contacts[0].update!(contact_id: @domain.registrant.id)
|
||||
@domain.admin_domain_contacts[0].update!(contact_id: @domain.registrant.id)
|
||||
|
||||
@domain.tech_domain_contacts[1].delete
|
||||
@domain.reload
|
||||
|
||||
post epp_transfer_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
|
||||
@domain.reload
|
||||
|
||||
admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id)
|
||||
tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id)
|
||||
|
||||
assert_equal @domain.contacts.where(original_id: @domain.registrant.original_id).count, 2
|
||||
|
||||
result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count)
|
||||
assert result_hash[@domain.registrant.original_id], 2
|
||||
|
||||
assert_equal admin.registrar_id, @domain.registrar.id
|
||||
assert_equal tech.registrar_id, @domain.registrar.id
|
||||
end
|
||||
|
||||
def test_transfers_domain_at_once
|
||||
post epp_transfer_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue