Skip to content

Commit

Permalink
Merge pull request #1150 from internetee/refactor-confirmation-url-vi…
Browse files Browse the repository at this point in the history
…ew-in-registrant-area

Refactor confirmation url view in registrant area
  • Loading branch information
vohmar authored Apr 8, 2019
2 parents 19fbfbd + 1dfc618 commit 35dddba
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 20 deletions.
28 changes: 14 additions & 14 deletions app/controllers/registrant/domains_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ def show
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

Expand Down Expand Up @@ -63,11 +63,11 @@ def normalize_search_parameters
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
Original file line number Diff line number Diff line change
Expand Up @@ -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}
2 changes: 1 addition & 1 deletion app/views/registrant/domains/partials/_statuses.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
1 change: 0 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 3 additions & 1 deletion config/locales/registrant/domains.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ en:

domain_contacts:
header_admin_domain_contacts: Administrative contacts
header_tech_domain_contacts: Technical contacts
header_tech_domain_contacts: Technical contacts
confirmation:
header: Personal domain verification url
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
end

member do
get 'domain_verification_url'
get 'confirmation'
end
end

Expand Down
11 changes: 11 additions & 0 deletions test/system/registrant_area/domains/details_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,15 @@ def test_registrant_user_cannot_access_domains_of_other_users
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

0 comments on commit 35dddba

Please sign in to comment.