diff --git a/app/api/repp/domain_transfers_v1.rb b/app/api/repp/domain_transfers_v1.rb index ea714a731..c6a48df6d 100644 --- a/app/api/repp/domain_transfers_v1.rb +++ b/app/api/repp/domain_transfers_v1.rb @@ -26,7 +26,7 @@ module Repp if domain if domain.transfer_code == transfer_code DomainTransfer.request(domain, new_registrar) - successful_domain_transfers << { type: 'domain_transfer' } + successful_domain_transfers << { type: 'domain_transfer', attributes: { domain_name: domain.name } } else errors << { title: "#{domain_name} transfer code is wrong" } end diff --git a/app/controllers/registrar/domain_transfers_controller.rb b/app/controllers/registrar/domain_transfers_controller.rb index 0c72b2d93..65127155e 100644 --- a/app/controllers/registrar/domain_transfers_controller.rb +++ b/app/controllers/registrar/domain_transfers_controller.rb @@ -51,11 +51,13 @@ class Registrar end end - if response.code == '204' - flash[:notice] = t '.transferred' + parsed_response = JSON.parse(response.body, symbolize_names: true) + + if response.code == '200' + flash[:notice] = t '.transferred', count: parsed_response[:data].size redirect_to registrar_domains_url else - @api_errors = JSON.parse(response.body, symbolize_names: true)[:errors] + @api_errors = parsed_response[:errors] render :new end else diff --git a/config/locales/registrar/domain_transfers.en.yml b/config/locales/registrar/domain_transfers.en.yml index 64663b558..d162110ce 100644 --- a/config/locales/registrar/domain_transfers.en.yml +++ b/config/locales/registrar/domain_transfers.en.yml @@ -8,7 +8,7 @@ en: create: header: Domain transfer - transferred: Domains have been successfully transferred + transferred: "%{count} domains have been successfully transferred" form: single: diff --git a/test/integration/api/domain_transfers_test.rb b/test/integration/api/domain_transfers_test.rb index 10675b507..b90b59be4 100644 --- a/test/integration/api/domain_transfers_test.rb +++ b/test/integration/api/domain_transfers_test.rb @@ -10,7 +10,10 @@ class APIDomainTransfersTest < ActionDispatch::IntegrationTest post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response 200 assert_equal ({ data: [{ - type: 'domain_transfer' + type: 'domain_transfer', + attributes: { + domain_name: 'shop.test' + }, }] }), JSON.parse(response.body, symbolize_names: true) end diff --git a/test/integration/registrar/domain_transfers_test.rb b/test/integration/registrar/domain_transfers_test.rb index 46a92859b..e29a11070 100644 --- a/test/integration/registrar/domain_transfers_test.rb +++ b/test/integration/registrar/domain_transfers_test.rb @@ -7,12 +7,14 @@ class RegistrarDomainTransfersTest < ActionDispatch::IntegrationTest end 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' } - request_stub = stub_request(:post, /domain_transfers/).with(body: body, + request_stub = stub_request(:post, /domain_transfers/).with(body: request_body, headers: headers, basic_auth: ['test_goodnames', 'testtest']) - .to_return(status: 204) + .to_return(body: { data: [{ + type: 'domain_transfer' + }] }.to_json, status: 200) visit registrar_domains_url click_link 'Transfer' @@ -23,7 +25,7 @@ class RegistrarDomainTransfersTest < ActionDispatch::IntegrationTest assert_requested request_stub assert_current_path registrar_domains_path - assert_text 'Domains have been successfully transferred' + assert_text '1 domains have been successfully transferred' end def test_batch_transfer_fails_gracefully diff --git a/test/models/contact/contact_transfer_test.rb b/test/models/contact/contact_transfer_test.rb index 6c403bb23..7346a6375 100644 --- a/test/models/contact/contact_transfer_test.rb +++ b/test/models/contact/contact_transfer_test.rb @@ -8,7 +8,6 @@ class ContactTransferTest < ActiveSupport::TestCase def test_invalid_without_auth_info @contact.auth_info = nil - @contact.validate assert @contact.invalid? end diff --git a/test/models/domain/transferable_test.rb b/test/models/domain/transferable_test.rb index c0de4992b..42613aa45 100644 --- a/test/models/domain/transferable_test.rb +++ b/test/models/domain/transferable_test.rb @@ -8,7 +8,6 @@ class DomainTransferableTest < ActiveSupport::TestCase def test_invalid_without_transfer_code @domain.transfer_code = nil - @domain.validate assert @domain.invalid? end