mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 06:34:46 +02:00
parent
84bc0f8914
commit
53a34ee2d6
9 changed files with 94 additions and 12 deletions
|
@ -3,6 +3,7 @@ require 'test_helper'
|
|||
class APIDomainTransfersTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
@new_registrar = registrars(:goodnames)
|
||||
Setting.transfer_wait_time = 0 # Auto-approval
|
||||
end
|
||||
|
||||
|
@ -29,10 +30,10 @@ class APIDomainTransfersTest < ActionDispatch::IntegrationTest
|
|||
assert @domain.transfers.last.approved?
|
||||
end
|
||||
|
||||
def test_changes_registrar
|
||||
def test_assigns_new_registrar
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
@domain.reload
|
||||
assert_equal registrars(:goodnames), @domain.registrar
|
||||
assert_equal @new_registrar, @domain.registrar
|
||||
end
|
||||
|
||||
def test_regenerates_transfer_code
|
||||
|
@ -52,11 +53,20 @@ class APIDomainTransfersTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
def test_duplicates_registrant_admin_and_tech_contacts
|
||||
assert_difference 'Contact.count', 3 do
|
||||
assert_difference -> { @new_registrar.contacts.size }, 2 do
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
end
|
||||
end
|
||||
|
||||
def test_reuses_identical_contact
|
||||
request_params = { format: :json,
|
||||
data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' },
|
||||
{ domainName: 'airport.test', transferCode: '55438j5' },
|
||||
{ domainName: 'library.test', transferCode: '45118f5' }] } }
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_equal 1, @new_registrar.contacts.where(name: 'William').size
|
||||
end
|
||||
|
||||
def test_fails_if_domain_does_not_exist
|
||||
request_params = { format: :json,
|
||||
data: { domainTransfers: [{ domainName: 'non-existent.test', transferCode: 'any' }] } }
|
||||
|
@ -71,7 +81,7 @@ class APIDomainTransfersTest < ActionDispatch::IntegrationTest
|
|||
data: { domainTransfers: [{ domainName: 'shop.test', transferCode: 'wrong' }] } }
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response 400
|
||||
refute_equal registrars(:goodnames), @domain.registrar
|
||||
refute_equal @new_registrar, @domain.registrar
|
||||
assert_equal ({ errors: [{ title: 'shop.test transfer code is wrong' }] }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue