Merge remote-tracking branch 'origin/fix-tech-nameserver-change-notifications' into fix-repp-registrar-bridge

This commit is contained in:
Karl Erik Õunapuu 2020-12-23 11:19:13 +02:00
commit d4347f16ce
No known key found for this signature in database
GPG key ID: C9DD647298A34764
7 changed files with 27 additions and 24 deletions

View file

@ -55,10 +55,12 @@ class Registrar
parsed_response = JSON.parse(response.body, symbolize_names: true)
if response.code == '200'
flash[:notice] = t '.transferred', count: parsed_response[:data].size
failed = parsed_response[:data][:failed].each(&:domain_name).join(', ')
flash[:notice] = t('.transferred', count: parsed_response[:data][:success].size,
failed: failed)
redirect_to registrar_domains_url
else
@api_errors = parsed_response[:errors]
@api_errors = parsed_response[:message]
render file: 'registrar/bulk_change/new', locals: { active_tab: :bulk_transfer }
end
else

View file

@ -43,16 +43,16 @@ class Registrar
if response.code == '200'
notices = [t('.replaced')]
notices << "#{t('.affected_domains')}: #{parsed_response[:affected_domains].join(', ')}"
notices << "#{t('.affected_domains')}: #{parsed_response[:data][:affected_domains].join(', ')}"
if parsed_response[:skipped_domains]
notices << "#{t('.skipped_domains')}: #{parsed_response[:skipped_domains].join(', ')}"
if parsed_response[:data][:skipped_domains]
notices << "#{t('.skipped_domains')}: #{parsed_response[:data][:skipped_domains].join(', ')}"
end
flash[:notice] = notices
flash[:notice] = notices.join(', ')
redirect_to registrar_domains_url
else
@error = parsed_response[:error]
@error = response.code == '404' ? 'Contact(s) not found' : parsed_response[:message]
render file: 'registrar/bulk_change/new', locals: { active_tab: :technical_contact }
end
end

View file

@ -5,19 +5,20 @@ class TechDomainContact < DomainContact
skipped_domains = []
tech_contacts = where(contact: current_contact)
transaction do
tech_contacts.each do |tech_contact|
if tech_contact.domain.discarded?
skipped_domains << tech_contact.domain.name
next
end
tech_contacts.each do |tech_contact|
if tech_contact.domain.discarded?
skipped_domains << tech_contact.domain.name
next
end
begin
tech_contact.contact = new_contact
tech_contact.save!
affected_domains << tech_contact.domain.name
rescue ActiveRecord::RecordNotUnique
skipped_domains << tech_contact.domain.name
end
end
return affected_domains.sort, skipped_domains.sort
[affected_domains.sort, skipped_domains.sort]
end
end

View file

@ -1,7 +1,7 @@
<%= form_tag registrar_tech_contacts_path, method: :patch, class: 'form-horizontal' do %>
<% if @error %>
<div class="alert alert-danger">
<%= @error[:message] %>
<%= @error %>
</div>
<% end %>

View file

@ -6,7 +6,7 @@ en:
create:
header: Domain transfer
transferred: "%{count} domains have been successfully transferred"
transferred: "%{count} domains have been successfully transferred. Failed domains: %{failed}"
form:
submit_btn: Transfer

View file

@ -11,9 +11,9 @@ class RegistrarAreaBulkTransferTest < ApplicationSystemTestCase
request_stub = stub_request(:post, /domains\/transfer/).with(body: request_body,
headers: headers,
basic_auth: ['test_goodnames', 'testtest'])
.to_return(body: { data: [{
type: 'domain_transfer'
}] }.to_json, status: 200)
.to_return(body: { data: { success: [{ type: 'domain_transfer', domain_name: 'shop.test' }],
failed: []
} }.to_json, status: 200)
visit registrar_domains_url
click_link 'Bulk change'
@ -27,7 +27,7 @@ class RegistrarAreaBulkTransferTest < ApplicationSystemTestCase
end
def test_fail_gracefully
body = { errors: [{ title: 'epic fail' }] }.to_json
body = { message: 'epic fail' }.to_json
headers = { 'Content-type' => Mime[:json] }
stub_request(:post, /domains\/transfer/).to_return(status: 400, body: body, headers: headers)

View file

@ -9,8 +9,8 @@ class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase
request_stub = stub_request(:patch, /domains\/contacts/)
.with(body: { current_contact_id: 'william-001', new_contact_id: 'john-001' },
basic_auth: ['test_bestnames', 'testtest'])
.to_return(body: { affected_domains: %w[foo.test bar.test],
skipped_domains: %w[baz.test qux.test] }.to_json,
.to_return(body: { data: { affected_domains: %w[foo.test bar.test],
skipped_domains: %w[baz.test qux.test] } }.to_json,
status: 200)
visit registrar_domains_url
@ -30,7 +30,7 @@ class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase
def test_fails_gracefully
stub_request(:patch, /domains\/contacts/)
.to_return(status: 400,
body: { error: { message: 'epic fail' } }.to_json,
body: { message: 'epic fail' }.to_json,
headers: { 'Content-type' => Mime[:json] })
visit registrar_domains_url