mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 10:45:58 +02:00
Merge pull request #1754 from internetee/1753-move-domain-delete-confirm-to-interactors
Move DomainDeleteConfirm job to interactor
This commit is contained in:
commit
8e7033f2c0
5 changed files with 33 additions and 28 deletions
|
@ -0,0 +1,22 @@
|
|||
module DomainDeleteConfirmInteraction
|
||||
class SendRequest < ActiveInteraction::Base
|
||||
object :domain,
|
||||
class: Domain,
|
||||
description: 'Domain to send delete confirmation'
|
||||
|
||||
def execute
|
||||
log
|
||||
DomainDeleteMailer.confirmation_request(domain: domain,
|
||||
registrar: domain.registrar,
|
||||
registrant: domain.registrant).deliver_later
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def log
|
||||
message = "Send DomainDeleteMailer#confirm email for domain #{domain.name} (##{domain.id})" \
|
||||
" to #{domain.registrant.email}"
|
||||
Rails.logger.info(message)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
class DomainDeleteConfirmEmailJob < Que::Job
|
||||
def run(domain_id)
|
||||
domain = Domain.find(domain_id)
|
||||
|
||||
log(domain)
|
||||
DomainDeleteMailer.confirmation_request(domain: domain,
|
||||
registrar: domain.registrar,
|
||||
registrant: domain.registrant).deliver_now
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def log(domain)
|
||||
message = "Send DomainDeleteMailer#confirm email for domain #{domain.name} (##{domain.id})" \
|
||||
" to #{domain.registrant.email}"
|
||||
logger.info(message)
|
||||
end
|
||||
|
||||
def logger
|
||||
Rails.logger
|
||||
end
|
||||
end
|
|
@ -418,7 +418,7 @@ class Domain < ApplicationRecord
|
|||
pending_delete_confirmation!
|
||||
save(validate: false) # should check if this did succeed
|
||||
|
||||
DomainDeleteConfirmEmailJob.enqueue(id)
|
||||
DomainDeleteConfirmInteraction::SendRequest.run(domain: self)
|
||||
end
|
||||
|
||||
def cancel_pending_delete
|
||||
|
|
|
@ -35,7 +35,6 @@ class EppDomainDeleteBaseTest < EppTestCase
|
|||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
# binding.pry
|
||||
assert_includes Domain.find_by(name: 'invalid.test').statuses, DomainStatus::PENDING_DELETE_CONFIRMATION
|
||||
assert_epp_response :completed_successfully_action_pending
|
||||
end
|
||||
|
@ -90,7 +89,9 @@ class EppDomainDeleteBaseTest < EppTestCase
|
|||
</epp>
|
||||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
perform_enqueued_jobs do
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert @domain.registrant_verification_asked?
|
||||
|
@ -121,7 +122,9 @@ class EppDomainDeleteBaseTest < EppTestCase
|
|||
</epp>
|
||||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
perform_enqueued_jobs do
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.registrant_verification_asked?
|
||||
|
@ -152,7 +155,9 @@ class EppDomainDeleteBaseTest < EppTestCase
|
|||
</epp>
|
||||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
perform_enqueued_jobs do
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.registrant_verification_asked?
|
||||
|
|
|
@ -70,6 +70,6 @@ class Whois::RecordTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def registration_deadline
|
||||
Time.zone.now + 10.days
|
||||
@registration_deadline ||= Time.zone.now + 10.days
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue