mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 22:54:47 +02:00
Fix CC issues
This commit is contained in:
parent
60a66bc540
commit
54eb1e91de
4 changed files with 78 additions and 47 deletions
|
@ -1,4 +1,15 @@
|
||||||
class ApplicationMailer < ActionMailer::Base
|
class ApplicationMailer < ActionMailer::Base
|
||||||
append_view_path Rails.root.join('app', 'views', 'mailers')
|
append_view_path Rails.root.join('app', 'views', 'mailers')
|
||||||
layout 'mailer'
|
layout 'mailer'
|
||||||
end
|
|
||||||
|
def registrant_confirm_url(domain:, method:)
|
||||||
|
token = domain.registrant_verification_token
|
||||||
|
base_url = ENV['registrant_portal_verifications_base_url']
|
||||||
|
|
||||||
|
url = registrant_domain_delete_confirm_url(domain, token: token) if method == 'delete'
|
||||||
|
url ||= registrant_domain_update_confirm_url(domain, token: token)
|
||||||
|
return url if base_url.blank?
|
||||||
|
|
||||||
|
"#{base_url}/confirms/#{domain.name_puny}/#{method}/#{token}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ class DomainDeleteMailer < ApplicationMailer
|
||||||
def confirmation_request(domain:, registrar:, registrant:)
|
def confirmation_request(domain:, registrar:, registrant:)
|
||||||
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
||||||
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
|
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
|
||||||
@confirmation_url = confirmation_url(domain)
|
@confirmation_url = registrant_confirm_url(domain: domain, method: 'delete')
|
||||||
|
|
||||||
subject = default_i18n_subject(domain_name: domain.name)
|
subject = default_i18n_subject(domain_name: domain.name)
|
||||||
mail(to: registrant.email, subject: subject)
|
mail(to: registrant.email, subject: subject)
|
||||||
|
@ -52,15 +52,6 @@ class DomainDeleteMailer < ApplicationMailer
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def confirmation_url(domain)
|
|
||||||
base_url = ENV['registrant_portal_verifications_base_url']
|
|
||||||
if base_url.blank?
|
|
||||||
registrant_domain_delete_confirm_url(domain, token: domain.registrant_verification_token)
|
|
||||||
else
|
|
||||||
"#{base_url}/confirmation/#{domain.name_puny}/delete/#{domain.registrant_verification_token}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def forced_email_from
|
def forced_email_from
|
||||||
ENV['action_mailer_force_delete_from'] || self.class.default[:from]
|
ENV['action_mailer_force_delete_from'] || self.class.default[:from]
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ class RegistrantChangeMailer < ApplicationMailer
|
||||||
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
||||||
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
|
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
|
||||||
@new_registrant = RegistrantPresenter.new(registrant: new_registrant, view: view_context)
|
@new_registrant = RegistrantPresenter.new(registrant: new_registrant, view: view_context)
|
||||||
@confirmation_url = confirmation_url(domain)
|
@confirmation_url = registrant_confirm_url(domain: domain, method: 'change')
|
||||||
|
|
||||||
subject = default_i18n_subject(domain_name: domain.name)
|
subject = default_i18n_subject(domain_name: domain.name)
|
||||||
mail(to: current_registrant.email, subject: subject)
|
mail(to: current_registrant.email, subject: subject)
|
||||||
|
@ -49,15 +49,6 @@ class RegistrantChangeMailer < ApplicationMailer
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def confirmation_url(domain)
|
|
||||||
base_url = ENV['registrant_portal_verifications_base_url']
|
|
||||||
if base_url.blank?
|
|
||||||
registrant_domain_update_confirm_url(domain, token: domain.registrant_verification_token)
|
|
||||||
else
|
|
||||||
"#{base_url}/confirmation/#{domain.name_puny}/change/#{domain.registrant_verification_token}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def address_processing
|
def address_processing
|
||||||
Contact.address_processing?
|
Contact.address_processing?
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,17 +8,22 @@ class RegistrantApiVerificationsTest < ApplicationIntegrationTest
|
||||||
@domain = domains(:hospital)
|
@domain = domains(:hospital)
|
||||||
@registrant = @domain.registrant
|
@registrant = @domain.registrant
|
||||||
@new_registrant = contacts(:jack)
|
@new_registrant = contacts(:jack)
|
||||||
|
@user = users(:api_bestnames)
|
||||||
|
|
||||||
@token = 'verysecrettoken'
|
@token = 'verysecrettoken'
|
||||||
|
|
||||||
@domain.update(statuses: [DomainStatus::PENDING_UPDATE],
|
@domain.update!(statuses: [DomainStatus::PENDING_UPDATE],
|
||||||
registrant_verification_asked_at: Time.zone.now - 1.day,
|
registrant_verification_asked_at: Time.zone.now - 1.day,
|
||||||
registrant_verification_token: @token)
|
registrant_verification_token: @token)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fetches_registrant_change_request
|
def test_fetches_registrant_change_request
|
||||||
pending_json = { new_registrant_id: @new_registrant.id }
|
pending_json = { new_registrant_id: @new_registrant.id,
|
||||||
|
new_registrant_name: @new_registrant.name,
|
||||||
|
new_registrant_email: @new_registrant.email,
|
||||||
|
current_user_id: @user.id }
|
||||||
|
|
||||||
@domain.update(pending_json: pending_json)
|
@domain.update(pending_json: pending_json)
|
||||||
@domain.reload
|
@domain.reload
|
||||||
|
|
||||||
|
@ -46,31 +51,40 @@ class RegistrantApiVerificationsTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_approves_registrant_change_request
|
def test_approves_registrant_change_request
|
||||||
pending_json = { new_registrant_id: @new_registrant.id }
|
pending_json = { new_registrant_id: @new_registrant.id,
|
||||||
@domain.update(pending_json: pending_json)
|
new_registrant_name: @new_registrant.name,
|
||||||
|
new_registrant_email: @new_registrant.email,
|
||||||
|
current_user_id: @user.id }
|
||||||
|
|
||||||
|
@domain.update!(pending_json: pending_json)
|
||||||
@domain.reload
|
@domain.reload
|
||||||
|
|
||||||
assert @domain.registrant_update_confirmable?(@token)
|
assert @domain.registrant_update_confirmable?(@token)
|
||||||
|
|
||||||
post "/api/v1/registrant/confirms/#{@domain.name_puny}/change/#{@token}/confirmed"
|
perform_enqueued_jobs do
|
||||||
assert_equal(200, response.status)
|
post "/api/v1/registrant/confirms/#{@domain.name_puny}/change/#{@token}/confirmed"
|
||||||
|
assert_equal(200, response.status)
|
||||||
|
|
||||||
res = JSON.parse(response.body, symbolize_names: true)
|
res = JSON.parse(response.body, symbolize_names: true)
|
||||||
expected_body = {
|
expected_body = {
|
||||||
domain_name: @domain.name,
|
domain_name: @domain.name,
|
||||||
current_registrant: {
|
current_registrant: {
|
||||||
name: @new_registrant.name,
|
name: @new_registrant.name,
|
||||||
ident: @new_registrant.ident,
|
ident: @new_registrant.ident,
|
||||||
country: @new_registrant.ident_country_code
|
country: @new_registrant.ident_country_code
|
||||||
},
|
},
|
||||||
status: 'confirmed'
|
status: 'confirmed'
|
||||||
}
|
}
|
||||||
|
assert_equal expected_body, res
|
||||||
assert_equal expected_body, res
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_rejects_registrant_change_request
|
def test_rejects_registrant_change_request
|
||||||
pending_json = { new_registrant_id: @new_registrant.id }
|
pending_json = { new_registrant_id: @new_registrant.id,
|
||||||
|
new_registrant_name: @new_registrant.name,
|
||||||
|
new_registrant_email: @new_registrant.email,
|
||||||
|
current_user_id: @user.id }
|
||||||
|
|
||||||
@domain.update(pending_json: pending_json)
|
@domain.update(pending_json: pending_json)
|
||||||
@domain.reload
|
@domain.reload
|
||||||
|
|
||||||
|
@ -94,7 +108,11 @@ class RegistrantApiVerificationsTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_registrant_change_requires_valid_attributes
|
def test_registrant_change_requires_valid_attributes
|
||||||
pending_json = { new_registrant_id: @new_registrant.id }
|
pending_json = { new_registrant_id: @new_registrant.id,
|
||||||
|
new_registrant_name: @new_registrant.name,
|
||||||
|
new_registrant_email: @new_registrant.email,
|
||||||
|
current_user_id: @user.id }
|
||||||
|
|
||||||
@domain.update(pending_json: pending_json)
|
@domain.update(pending_json: pending_json)
|
||||||
@domain.reload
|
@domain.reload
|
||||||
|
|
||||||
|
@ -109,7 +127,12 @@ class RegistrantApiVerificationsTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fetches_domain_delete_request
|
def test_fetches_domain_delete_request
|
||||||
@domain.update(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
pending_json = { new_registrant_id: @new_registrant.id,
|
||||||
|
new_registrant_name: @new_registrant.name,
|
||||||
|
new_registrant_email: @new_registrant.email,
|
||||||
|
current_user_id: @user.id }
|
||||||
|
|
||||||
|
@domain.update(pending_json: pending_json, statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
||||||
@domain.reload
|
@domain.reload
|
||||||
|
|
||||||
assert @domain.registrant_delete_confirmable?(@token)
|
assert @domain.registrant_delete_confirmable?(@token)
|
||||||
|
@ -131,8 +154,13 @@ class RegistrantApiVerificationsTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_approves_domain_delete_request
|
def test_approves_domain_delete_request
|
||||||
@domain.update(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
pending_json = { new_registrant_id: @new_registrant.id,
|
||||||
@domain.reload
|
new_registrant_name: @new_registrant.name,
|
||||||
|
new_registrant_email: @new_registrant.email,
|
||||||
|
current_user_id: @user.id }
|
||||||
|
|
||||||
|
@domain.update(pending_json: pending_json, statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
||||||
|
@domain.reload
|
||||||
|
|
||||||
assert @domain.registrant_delete_confirmable?(@token)
|
assert @domain.registrant_delete_confirmable?(@token)
|
||||||
|
|
||||||
|
@ -154,8 +182,13 @@ class RegistrantApiVerificationsTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_rejects_domain_delete_request
|
def test_rejects_domain_delete_request
|
||||||
@domain.update(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
pending_json = { new_registrant_id: @new_registrant.id,
|
||||||
@domain.reload
|
new_registrant_name: @new_registrant.name,
|
||||||
|
new_registrant_email: @new_registrant.email,
|
||||||
|
current_user_id: @user.id }
|
||||||
|
|
||||||
|
@domain.update(pending_json: pending_json, statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
||||||
|
@domain.reload
|
||||||
|
|
||||||
assert @domain.registrant_delete_confirmable?(@token)
|
assert @domain.registrant_delete_confirmable?(@token)
|
||||||
|
|
||||||
|
@ -177,7 +210,12 @@ class RegistrantApiVerificationsTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_domain_delete_requires_valid_attributes
|
def test_domain_delete_requires_valid_attributes
|
||||||
@domain.update(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION, DomainStatus::PENDING_DELETE])
|
pending_json = { new_registrant_id: @new_registrant.id,
|
||||||
|
new_registrant_name: @new_registrant.name,
|
||||||
|
new_registrant_email: @new_registrant.email,
|
||||||
|
current_user_id: @user.id }
|
||||||
|
|
||||||
|
@domain.update(pending_json: pending_json, statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
||||||
@domain.reload
|
@domain.reload
|
||||||
|
|
||||||
get "/api/v1/registrant/confirms/#{@domain.name_puny}/delete/123"
|
get "/api/v1/registrant/confirms/#{@domain.name_puny}/delete/123"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue