mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 21:25:39 +02:00
Transfer: Return identical objects occassionally
This commit is contained in:
parent
6318535fe1
commit
40d68fc7f1
4 changed files with 13 additions and 9 deletions
|
@ -7,6 +7,8 @@ module Concerns::Contact::Transferable
|
|||
end
|
||||
|
||||
def transfer(new_registrar)
|
||||
return identical(new_registrar) if identical_with_registrar?(new_registrar)
|
||||
|
||||
new_contact = self.dup
|
||||
new_contact.registrar = new_registrar
|
||||
new_contact.original = self
|
||||
|
@ -21,6 +23,13 @@ module Concerns::Contact::Transferable
|
|||
|
||||
protected
|
||||
|
||||
def identical_with_registrar?(registrar)
|
||||
return false unless identical(registrar)
|
||||
return true unless DomainContact.where(contact_id: id).any?
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
def generate_auth_info
|
||||
self.auth_info = SecureRandom.hex(11)
|
||||
end
|
||||
|
|
|
@ -64,7 +64,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_duplicates_registrant_admin_and_tech_contacts
|
||||
assert_difference -> { @new_registrar.contacts.size }, 3 do
|
||||
assert_difference -> { @new_registrar.contacts.size }, 4 do
|
||||
post '/repp/v1/domain_transfers', params: request_params, as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
end
|
||||
|
@ -73,7 +73,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
|
|||
def test_reuses_identical_contact
|
||||
post '/repp/v1/domain_transfers', params: request_params, as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_equal 1, @new_registrar.contacts.where(name: 'William').size
|
||||
assert_equal 2, @new_registrar.contacts.where(name: 'William').size
|
||||
end
|
||||
|
||||
def test_fails_if_domain_does_not_exist
|
||||
|
|
|
@ -59,7 +59,7 @@ class EppDomainTransferRequestTest < EppTestCase
|
|||
end
|
||||
|
||||
def test_duplicates_registrant_admin_and_tech_contacts
|
||||
assert_difference -> { @new_registrar.contacts.size }, 3 do
|
||||
assert_difference -> { @new_registrar.contacts.size }, 4 do
|
||||
post epp_transfer_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
end
|
||||
|
@ -68,7 +68,7 @@ class EppDomainTransferRequestTest < EppTestCase
|
|||
def test_reuses_identical_contact
|
||||
post epp_transfer_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
assert_equal 1, @new_registrar.contacts.where(name: 'William').size
|
||||
assert_equal 2, @new_registrar.contacts.where(name: 'William').size
|
||||
end
|
||||
|
||||
def test_saves_legal_document
|
||||
|
|
|
@ -47,11 +47,6 @@ class ContactTransferTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_reuses_identical_contact
|
||||
identical = contacts(:identical_to_william)
|
||||
assert_equal identical, contacts(:william).transfer(@new_registrar)
|
||||
end
|
||||
|
||||
def test_bypasses_validation
|
||||
@contact = contacts(:invalid)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue