Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move DomainDeleteConfirm job to interactor #1754

Merged
merged 3 commits into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app/interactions/domain_delete_confirm_interaction/send_request.rb
Original file line number Diff line number Diff line change
@@ -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
22 changes: 0 additions & 22 deletions app/jobs/domain_delete_confirm_email_job.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/models/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def pending_delete!
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
Expand Down
13 changes: 9 additions & 4 deletions test/integration/epp/domain/delete/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def test_bypasses_domain_and_registrant_and_contacts_validation
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
Expand Down Expand Up @@ -90,7 +89,9 @@ def test_requests_registrant_confirmation_when_required
</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?
Expand Down Expand Up @@ -121,7 +122,9 @@ def test_skips_registrant_confirmation_when_not_required
</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?
Expand Down Expand Up @@ -152,7 +155,9 @@ def test_skips_registrant_confirmation_when_required_but_already_verified_by_reg
</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?
Expand Down
2 changes: 1 addition & 1 deletion test/models/whois/record_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ def test_updates_whois_record_from_auction_when_payment_received
end

def registration_deadline
Time.zone.now + 10.days
@registration_deadline ||= Time.zone.now + 10.days
end
end