mirror of
https://github.com/internetee/registry.git
synced 2025-06-12 15:44:45 +02:00
Merge branch 'registry-693' into registry-694
This commit is contained in:
commit
f8e52fc8d0
3 changed files with 22 additions and 6 deletions
|
@ -15,6 +15,7 @@ module Repp
|
||||||
|
|
||||||
new_registrar = current_user.registrar
|
new_registrar = current_user.registrar
|
||||||
domain_transfers = params['data']['domainTransfers']
|
domain_transfers = params['data']['domainTransfers']
|
||||||
|
successful_domain_transfers = []
|
||||||
errors = []
|
errors = []
|
||||||
|
|
||||||
domain_transfers.each do |domain_transfer|
|
domain_transfers.each do |domain_transfer|
|
||||||
|
@ -25,6 +26,7 @@ module Repp
|
||||||
if domain
|
if domain
|
||||||
if domain.transfer_code == transfer_code
|
if domain.transfer_code == transfer_code
|
||||||
domain.transfer(new_registrar)
|
domain.transfer(new_registrar)
|
||||||
|
successful_domain_transfers << { type: 'domain_transfer' }
|
||||||
else
|
else
|
||||||
errors << { title: "#{domain_name} transfer code is wrong" }
|
errors << { title: "#{domain_name} transfer code is wrong" }
|
||||||
end
|
end
|
||||||
|
@ -34,9 +36,8 @@ module Repp
|
||||||
end
|
end
|
||||||
|
|
||||||
if errors.none?
|
if errors.none?
|
||||||
status 204
|
status 200
|
||||||
body false
|
@response = { data: successful_domain_transfers }
|
||||||
@response = {}
|
|
||||||
else
|
else
|
||||||
status 400
|
status 400
|
||||||
@response = { errors: errors }
|
@response = { errors: errors }
|
||||||
|
|
|
@ -28,9 +28,21 @@ Authorization: Basic dGVzdDp0ZXN0dGVzdA==
|
||||||
|
|
||||||
#### Response on success
|
#### Response on success
|
||||||
```
|
```
|
||||||
HTTP/1.1 204
|
HTTP/1.1 200
|
||||||
|
Content-Type: application/json
|
||||||
|
{
|
||||||
|
"data":[
|
||||||
|
{
|
||||||
|
"type":"domain_transfer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type":"domain_transfer"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
#### Response on failure
|
#### Response on failure
|
||||||
```
|
```
|
||||||
HTTP/1.1 400
|
HTTP/1.1 400
|
||||||
|
|
|
@ -5,9 +5,12 @@ class APIDomainTransfersTest < ActionDispatch::IntegrationTest
|
||||||
request_params = { format: :json,
|
request_params = { format: :json,
|
||||||
data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } }
|
data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } }
|
||||||
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 204
|
|
||||||
assert_equal registrars(:goodnames), domains(:shop).registrar
|
assert_equal registrars(:goodnames), domains(:shop).registrar
|
||||||
assert_empty response.body
|
assert_response 200
|
||||||
|
assert_equal ({ data: [{
|
||||||
|
type: 'domain_transfer'
|
||||||
|
}] }),
|
||||||
|
JSON.parse(response.body, symbolize_names: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fails_if_domain_does_not_exist
|
def test_fails_if_domain_does_not_exist
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue