mirror of
https://github.com/internetee/registry.git
synced 2025-06-13 08:04:45 +02:00
Merge pull request #722 from internetee/registry-693
REST API: Return successful domain transfers
This commit is contained in:
commit
7c45a85cea
7 changed files with 17 additions and 12 deletions
|
@ -26,7 +26,7 @@ module Repp
|
||||||
if domain
|
if domain
|
||||||
if domain.transfer_code == transfer_code
|
if domain.transfer_code == transfer_code
|
||||||
DomainTransfer.request(domain, new_registrar)
|
DomainTransfer.request(domain, new_registrar)
|
||||||
successful_domain_transfers << { type: 'domain_transfer' }
|
successful_domain_transfers << { type: 'domain_transfer', attributes: { domain_name: domain.name } }
|
||||||
else
|
else
|
||||||
errors << { title: "#{domain_name} transfer code is wrong" }
|
errors << { title: "#{domain_name} transfer code is wrong" }
|
||||||
end
|
end
|
||||||
|
|
|
@ -51,11 +51,13 @@ class Registrar
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if response.code == '204'
|
parsed_response = JSON.parse(response.body, symbolize_names: true)
|
||||||
flash[:notice] = t '.transferred'
|
|
||||||
|
if response.code == '200'
|
||||||
|
flash[:notice] = t '.transferred', count: parsed_response[:data].size
|
||||||
redirect_to registrar_domains_url
|
redirect_to registrar_domains_url
|
||||||
else
|
else
|
||||||
@api_errors = JSON.parse(response.body, symbolize_names: true)[:errors]
|
@api_errors = parsed_response[:errors]
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
@ -8,7 +8,7 @@ en:
|
||||||
|
|
||||||
create:
|
create:
|
||||||
header: Domain transfer
|
header: Domain transfer
|
||||||
transferred: Domains have been successfully transferred
|
transferred: "%{count} domains have been successfully transferred"
|
||||||
|
|
||||||
form:
|
form:
|
||||||
single:
|
single:
|
||||||
|
|
|
@ -10,7 +10,10 @@ class APIDomainTransfersTest < ActionDispatch::IntegrationTest
|
||||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||||
assert_response 200
|
assert_response 200
|
||||||
assert_equal ({ data: [{
|
assert_equal ({ data: [{
|
||||||
type: 'domain_transfer'
|
type: 'domain_transfer',
|
||||||
|
attributes: {
|
||||||
|
domain_name: 'shop.test'
|
||||||
|
},
|
||||||
}] }),
|
}] }),
|
||||||
JSON.parse(response.body, symbolize_names: true)
|
JSON.parse(response.body, symbolize_names: true)
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,12 +7,14 @@ class RegistrarDomainTransfersTest < ActionDispatch::IntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_batch_transfer_succeeds
|
def test_batch_transfer_succeeds
|
||||||
body = { data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } }
|
request_body = { data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } }
|
||||||
headers = { 'Content-type' => 'application/json' }
|
headers = { 'Content-type' => 'application/json' }
|
||||||
request_stub = stub_request(:post, /domain_transfers/).with(body: body,
|
request_stub = stub_request(:post, /domain_transfers/).with(body: request_body,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
basic_auth: ['test_goodnames', 'testtest'])
|
basic_auth: ['test_goodnames', 'testtest'])
|
||||||
.to_return(status: 204)
|
.to_return(body: { data: [{
|
||||||
|
type: 'domain_transfer'
|
||||||
|
}] }.to_json, status: 200)
|
||||||
|
|
||||||
visit registrar_domains_url
|
visit registrar_domains_url
|
||||||
click_link 'Transfer'
|
click_link 'Transfer'
|
||||||
|
@ -23,7 +25,7 @@ class RegistrarDomainTransfersTest < ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
assert_requested request_stub
|
assert_requested request_stub
|
||||||
assert_current_path registrar_domains_path
|
assert_current_path registrar_domains_path
|
||||||
assert_text 'Domains have been successfully transferred'
|
assert_text '1 domains have been successfully transferred'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_batch_transfer_fails_gracefully
|
def test_batch_transfer_fails_gracefully
|
||||||
|
|
|
@ -8,7 +8,6 @@ class ContactTransferTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def test_invalid_without_auth_info
|
def test_invalid_without_auth_info
|
||||||
@contact.auth_info = nil
|
@contact.auth_info = nil
|
||||||
@contact.validate
|
|
||||||
assert @contact.invalid?
|
assert @contact.invalid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ class DomainTransferableTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def test_invalid_without_transfer_code
|
def test_invalid_without_transfer_code
|
||||||
@domain.transfer_code = nil
|
@domain.transfer_code = nil
|
||||||
@domain.validate
|
|
||||||
assert @domain.invalid?
|
assert @domain.invalid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue