Change email sending from job to delayed send

This commit is contained in:
Alex Sherman 2020-11-23 16:57:28 +05:00
parent a3e6bc4cf9
commit cb3cf37331
4 changed files with 15 additions and 10 deletions

View file

@ -8,7 +8,7 @@ module DomainDeleteConfirmInteraction
log log
DomainDeleteMailer.confirmation_request(domain: domain, DomainDeleteMailer.confirmation_request(domain: domain,
registrar: domain.registrar, registrar: domain.registrar,
registrant: domain.registrant).deliver_now registrant: domain.registrant).deliver_later
end end
private private

View file

@ -1,6 +1,6 @@
class DomainDeleteConfirmEmailJob < Que::Job class DomainDeleteConfirmEmailJob < Que::Job
def run(domain_id) # def run(domain_id)
domain = Domain.find(domain_id) # domain = Domain.find(domain_id)
DomainDeleteConfirmInteraction::SendRequest.run(domain: domain) # DomainDeleteConfirmInteraction::SendRequest.run(domain: domain)
end # end
end end

View file

@ -418,7 +418,7 @@ class Domain < ApplicationRecord
pending_delete_confirmation! pending_delete_confirmation!
save(validate: false) # should check if this did succeed save(validate: false) # should check if this did succeed
DomainDeleteConfirmEmailJob.enqueue(id) DomainDeleteConfirmInteraction::SendRequest.run(domain: self)
end end
def cancel_pending_delete def cancel_pending_delete

View file

@ -35,7 +35,6 @@ class EppDomainDeleteBaseTest < EppTestCase
XML XML
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } 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_includes Domain.find_by(name: 'invalid.test').statuses, DomainStatus::PENDING_DELETE_CONFIRMATION
assert_epp_response :completed_successfully_action_pending assert_epp_response :completed_successfully_action_pending
end end
@ -90,7 +89,9 @@ class EppDomainDeleteBaseTest < EppTestCase
</epp> </epp>
XML 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 @domain.reload
assert @domain.registrant_verification_asked? assert @domain.registrant_verification_asked?
@ -121,7 +122,9 @@ class EppDomainDeleteBaseTest < EppTestCase
</epp> </epp>
XML 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 @domain.reload
assert_not @domain.registrant_verification_asked? assert_not @domain.registrant_verification_asked?
@ -152,7 +155,9 @@ class EppDomainDeleteBaseTest < EppTestCase
</epp> </epp>
XML 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 @domain.reload
assert_not @domain.registrant_verification_asked? assert_not @domain.registrant_verification_asked?