Add semantic test fixes & maybe solution for an issue

This commit is contained in:
Alex Sherman 2021-01-22 16:07:26 +05:00
parent 541c2d769a
commit 21fc5edb44
2 changed files with 12 additions and 11 deletions

View file

@ -59,7 +59,7 @@ module Concerns::Domain::Transferable
copied_ids = [] copied_ids = []
domain_contacts.each do |dc| domain_contacts.each do |dc|
contact = Contact.find(dc.contact_id) 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 if registrant_id_was == contact.id # registrant was copied previously, do not copy it again
oc = OpenStruct.new(id: registrant_id) oc = OpenStruct.new(id: registrant_id)
@ -72,7 +72,11 @@ module Concerns::Domain::Transferable
else else
dc.update(contact_id: oc.id) dc.update(contact_id: oc.id)
end end
copied_ids << contact.id copied_ids << uniq_contact_hash(dc)
end end
end end
def uniq_contact_hash(contact)
Digest::SHA1.hexdigest(contact.contact_id.to_s + contact.type)
end
end end

View file

@ -14,16 +14,11 @@ class EppDomainTransferRequestTest < EppTestCase
def test_new_contacts_should_be_created_after_transfer_domain def test_new_contacts_should_be_created_after_transfer_domain
registrar_id = @domain.registrar.id registrar_id = @domain.registrar.id
contacts_id_values = []
contact_id = Contact.find_by(registrar_id: registrar_id) new_contact = Contact.find_by(registrar_id: registrar_id)
@domain.domain_contacts[0].update!(contact_id: contact_id.id) @domain.domain_contacts[0].update!(contact_id: new_contact.id)
@domain.domain_contacts[1].update!(contact_id: contact_id.id) @domain.domain_contacts[1].update!(contact_id: new_contact.id)
@domain.domain_contacts.each do |contact|
contacts_id_values.push(contact.contact_id)
end
post epp_transfer_path, params: { frame: request_xml }, post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
@ -31,7 +26,9 @@ class EppDomainTransferRequestTest < EppTestCase
@domain.reload @domain.reload
assert_epp_response :completed_successfully assert_epp_response :completed_successfully
assert_equal @domain.domain_contacts[0].contact_id, @domain.domain_contacts[1].contact_id
result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count)
assert_equal result_hash[new_contact.id], 2
end end
def test_transfers_domain_at_once def test_transfers_domain_at_once