diff --git a/app/controllers/registrant/domains_controller.rb b/app/controllers/registrant/domains_controller.rb index f1b1b392d..b8cd8f37a 100644 --- a/app/controllers/registrant/domains_controller.rb +++ b/app/controllers/registrant/domains_controller.rb @@ -16,19 +16,19 @@ class Registrant::DomainsController < RegistrantController authorize! :read, @domain end - def domain_verification_url + def confirmation authorize! :view, :registrant_domains - dom = current_user_domains.find(params[:id]) - if (dom.statuses.include?(DomainStatus::PENDING_UPDATE) || dom.statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)) && - dom.pending_json.present? + domain = current_user_domains.find(params[:id]) - @domain = dom - confirm_path = get_confirm_path(dom.statuses) - @verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}" + if (domain.statuses.include?(DomainStatus::PENDING_UPDATE) || + domain.statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)) && + domain.pending_json.present? + @domain = domain + @confirmation_url = confirmation_url(domain) else flash[:warning] = I18n.t('available_verification_url_not_found') - redirect_to registrant_domain_path(dom.id) + redirect_to registrant_domain_path(domain) end end @@ -63,11 +63,11 @@ class Registrant::DomainsController < RegistrantController params[:q][:valid_to_lteq] = ca_cache end - def get_confirm_path(statuses) - if statuses.include?(DomainStatus::PENDING_UPDATE) - "#{ENV['registrant_url']}/registrant/domain_update_confirms" - elsif statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION) - "#{ENV['registrant_url']}/registrant/domain_delete_confirms" + def confirmation_url(domain) + if domain.statuses.include?(DomainStatus::PENDING_UPDATE) + registrant_domain_update_confirm_url(token: domain.registrant_verification_token) + elsif domain.statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION) + registrant_domain_delete_confirm_url(token: domain.registrant_verification_token) end end -end +end \ No newline at end of file diff --git a/app/views/registrant/domains/domain_verification_url.haml b/app/views/registrant/domains/confirmation.haml similarity index 75% rename from app/views/registrant/domains/domain_verification_url.haml rename to app/views/registrant/domains/confirmation.haml index f75091a2e..b1bc0cb2f 100644 --- a/app/views/registrant/domains/domain_verification_url.haml +++ b/app/views/registrant/domains/confirmation.haml @@ -5,9 +5,9 @@ .col-md-12 .panel.panel-default .panel-heading - %h3.panel-title= t(:personal_domain_verification_url) + %h3.panel-title= t('.header') .panel-body .input-group.input-group-lg %span#sizing-addon1.input-group-addon.glyphicon.glyphicon-link - %input.form-control{"aria-describedby" => "sizing-addon1", type: "text", value: @verification_url} + %input.form-control{"aria-describedby" => "sizing-addon1", type: "text", value: @confirmation_url} diff --git a/app/views/registrant/domains/partials/_statuses.haml b/app/views/registrant/domains/partials/_statuses.haml index 90a969324..10fc795eb 100644 --- a/app/views/registrant/domains/partials/_statuses.haml +++ b/app/views/registrant/domains/partials/_statuses.haml @@ -12,7 +12,7 @@ %tr %td - if [DomainStatus::PENDING_UPDATE, DomainStatus::PENDING_DELETE_CONFIRMATION].include?(status) && @domain.pending_json.present? - = link_to(status, domain_verification_url_registrant_domain_url(@domain.id)) + = link_to(status, confirmation_registrant_domain_path(@domain)) - else = status %td= @domain.status_notes[status] diff --git a/config/locales/en.yml b/config/locales/en.yml index 75e65f602..3e6e01a1c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -675,7 +675,6 @@ en: contact_is_not_valid: 'Contact %{value} is not valid, please fix the invalid contact' next: 'Next' previous: 'Previous' - personal_domain_verification_url: 'Personal domain verification url' available_verification_url_not_found: 'Available verification url not found, for domain.' add_reserved_domain: 'Add domain to reserved list' add_blocked_domain: 'Add domain to blocked list' diff --git a/config/locales/registrant/domains.en.yml b/config/locales/registrant/domains.en.yml index 596881f41..2dbdce79a 100644 --- a/config/locales/registrant/domains.en.yml +++ b/config/locales/registrant/domains.en.yml @@ -15,4 +15,6 @@ en: domain_contacts: header_admin_domain_contacts: Administrative contacts - header_tech_domain_contacts: Technical contacts \ No newline at end of file + header_tech_domain_contacts: Technical contacts + confirmation: + header: Personal domain verification url \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 453ac067a..1c9350327 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -156,7 +156,7 @@ Rails.application.routes.draw do end member do - get 'domain_verification_url' + get 'confirmation' end end diff --git a/test/system/registrant_area/domains/details_test.rb b/test/system/registrant_area/domains/details_test.rb index b23686b97..5ebff3e28 100644 --- a/test/system/registrant_area/domains/details_test.rb +++ b/test/system/registrant_area/domains/details_test.rb @@ -62,4 +62,15 @@ class RegistrantAreaDomainDetailsTest < ApplicationSystemTestCase assert_no_text 'metro.test' end end + + def test_confirmation_url + @domain.update!(registrant_verification_token: 'a01', + pending_json: { new_registrant_email: 'any' }, + statuses: [DomainStatus::PENDING_UPDATE]) + + visit registrant_domain_url(@domain) + click_on 'pendingUpdate' + + assert_field nil, with: registrant_domain_update_confirm_url(@domain, token: 'a01') + end end \ No newline at end of file