From 6fb1e44ccaac9fa872b01183bf41b4898c637dd0 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 5 Jul 2018 17:53:03 +0300 Subject: [PATCH] Move affected domains to the top of the hash, update integration test --- app/api/repp/nameservers_v1.rb | 4 ++-- app/controllers/registrar/nameservers_controller.rb | 5 ++++- config/locales/registrar/nameservers.en.yml | 1 + doc/repp/v1/nameservers.md | 6 +++--- test/integration/api/nameservers/put_test.rb | 4 ++-- test/integration/registrar/bulk_change/nameserver_test.rb | 6 +++--- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/api/repp/nameservers_v1.rb b/app/api/repp/nameservers_v1.rb index 71fde5aba..41a735b09 100644 --- a/app/api/repp/nameservers_v1.rb +++ b/app/api/repp/nameservers_v1.rb @@ -37,8 +37,8 @@ module Repp status 200 @response = { data: { type: 'nameserver', id: params[:data][:attributes][:hostname], - attributes: params[:data][:attributes], - affected_domains: affected_domains } } + attributes: params[:data][:attributes]}, + affected_domains: affected_domains } end end end diff --git a/app/controllers/registrar/nameservers_controller.rb b/app/controllers/registrar/nameservers_controller.rb index b6f7af829..3b70059a2 100644 --- a/app/controllers/registrar/nameservers_controller.rb +++ b/app/controllers/registrar/nameservers_controller.rb @@ -44,7 +44,10 @@ class Registrar parsed_response = JSON.parse(response.body, symbolize_names: true) if response.code == '200' - flash[:notice] = t '.replaced' + notices = [t('.replaced')] + notices << "#{t('.affected_domains')}: #{parsed_response[:affected_domains].join(', ')}" + + flash[:notice] = notices redirect_to registrar_domains_url else @api_errors = parsed_response[:errors] diff --git a/config/locales/registrar/nameservers.en.yml b/config/locales/registrar/nameservers.en.yml index fbe4c387e..6cc08f0ab 100644 --- a/config/locales/registrar/nameservers.en.yml +++ b/config/locales/registrar/nameservers.en.yml @@ -3,3 +3,4 @@ en: nameservers: update: replaced: Nameserver have been successfully replaced + affected_domains: Affected domains diff --git a/doc/repp/v1/nameservers.md b/doc/repp/v1/nameservers.md index c1269f92a..8190530d7 100644 --- a/doc/repp/v1/nameservers.md +++ b/doc/repp/v1/nameservers.md @@ -34,9 +34,9 @@ Content-Type: application/json "hostname": "new-ns1.example.com", "ipv4": ["192.0.2.1", "192.0.2.2"], "ipv6": ["2001:db8::1", "2001:db8::2"] - }, - "affected_domains": ["example.com", "example.org"] - } + } + }, + "affected_domains": ["example.com", "example.org"] } ``` diff --git a/test/integration/api/nameservers/put_test.rb b/test/integration/api/nameservers/put_test.rb index e840cfcfc..0967a1169 100644 --- a/test/integration/api/nameservers/put_test.rb +++ b/test/integration/api/nameservers/put_test.rb @@ -54,8 +54,8 @@ class APINameserversPutTest < ActionDispatch::IntegrationTest id: 'ns55.bestnames.test', attributes: { hostname: 'ns55.bestnames.test', ipv4: ['192.0.2.55'], - ipv6: ['2001:db8::55'] }, - affected_domains: ["airport.test", "shop.test"] } }), + ipv6: ['2001:db8::55'] }}, + affected_domains: ["airport.test", "shop.test"] }), JSON.parse(response.body, symbolize_names: true) end diff --git a/test/integration/registrar/bulk_change/nameserver_test.rb b/test/integration/registrar/bulk_change/nameserver_test.rb index d1dbfc012..841e68db5 100644 --- a/test/integration/registrar/bulk_change/nameserver_test.rb +++ b/test/integration/registrar/bulk_change/nameserver_test.rb @@ -16,9 +16,8 @@ class RegistrarAreaNameserverBulkChangeTest < ActionDispatch::IntegrationTest basic_auth: ['test_goodnames', 'testtest']) .to_return(body: { data: [{ type: 'nameserver', - id: 'new-ns.bestnames.test', - affected_domains: ["airport.test", "shop.test"] - }] }.to_json, status: 200) + id: 'new-ns.bestnames.test'}], + affected_domains: ["airport.test", "shop.test"]}.to_json, status: 200) visit registrar_domains_url click_link 'Bulk change' @@ -33,6 +32,7 @@ class RegistrarAreaNameserverBulkChangeTest < ActionDispatch::IntegrationTest assert_requested request_stub assert_current_path registrar_domains_path assert_text 'Nameserver have been successfully replaced' + assert_text 'Affected domains: airport.test, shop.test' end def test_fails_gracefully