mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 23:24:48 +02:00
parent
8e0226f4fb
commit
6a7a705fa8
4 changed files with 7 additions and 70 deletions
4
.reek
4
.reek
|
@ -476,7 +476,6 @@ IrresponsibleModule:
|
|||
- Registrar::ApplicationHelper
|
||||
- DomainDeleteConfirmEmailJob
|
||||
- DomainDeleteConfirmJob
|
||||
- DomainDeleteForcedEmailJob
|
||||
- DomainDeleteJob
|
||||
- DomainExpireEmailJob
|
||||
- DomainUpdateConfirmJob
|
||||
|
@ -855,7 +854,6 @@ UtilityFunction:
|
|||
- ApplicationHelper#plain_username
|
||||
- ApplicationHelper#unstable_env
|
||||
- DomainDeleteConfirmEmailJob#logger
|
||||
- DomainDeleteForcedEmailJob#logger
|
||||
- DomainExpireEmailJob#run
|
||||
- RegenerateRegistrarWhoisesJob#run
|
||||
- RegistrantChangeConfirmEmailJob#logger
|
||||
|
@ -894,8 +892,6 @@ FeatureEnvy:
|
|||
- DomainDeleteConfirmEmailJob#run
|
||||
- DomainDeleteConfirmJob#raise_errors!
|
||||
- DomainDeleteConfirmJob#run
|
||||
- DomainDeleteForcedEmailJob#log
|
||||
- DomainDeleteForcedEmailJob#run
|
||||
- DomainDeleteJob#run
|
||||
- DomainUpdateConfirmJob#raise_errors!
|
||||
- DomainUpdateConfirmJob#run
|
||||
|
|
|
@ -68,7 +68,13 @@ module Admin
|
|||
@domain.transaction do
|
||||
@domain.schedule_force_delete
|
||||
@domain.registrar.messages.create!(body: I18n.t('force_delete_set_on_domain', domain_name: @domain.name))
|
||||
DomainDeleteForcedEmailJob.enqueue(@domain.id, params[:template_name]) if notify_by_email?
|
||||
|
||||
if notify_by_email?
|
||||
DomainDeleteMailer.forced(domain: @domain,
|
||||
registrar: @domain.registrar,
|
||||
registrant: @domain.registrant,
|
||||
template_name: params[:template_name]).deliver_now
|
||||
end
|
||||
end
|
||||
|
||||
redirect_to edit_admin_domain_url(@domain), notice: t('.scheduled')
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
class DomainDeleteForcedEmailJob < Que::Job
|
||||
def run(domain_id, template_name)
|
||||
domain = Domain.find(domain_id)
|
||||
|
||||
log(domain)
|
||||
DomainDeleteMailer.forced(domain: domain,
|
||||
registrar: domain.registrar,
|
||||
registrant: domain.registrant,
|
||||
template_name: template_name).deliver_now
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def log(domain)
|
||||
message = "Send DomainDeleteMailer#forced email for domain #{domain.name} (##{domain.id})" \
|
||||
" to #{domain.primary_contact_emails.join(', ')}"
|
||||
logger.info(message)
|
||||
end
|
||||
|
||||
def logger
|
||||
Rails.logger
|
||||
end
|
||||
end
|
|
@ -1,42 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe DomainDeleteForcedEmailJob do
|
||||
describe '#run' do
|
||||
let(:domain) { instance_double(Domain) }
|
||||
let(:message) { instance_double(ActionMailer::MessageDelivery) }
|
||||
|
||||
before :example do
|
||||
expect(Domain).to receive(:find).and_return(domain)
|
||||
allow(domain).to receive_messages(
|
||||
id: 1,
|
||||
name: 'test.com',
|
||||
registrar: 'registrar',
|
||||
registrant: 'registrant',
|
||||
primary_contact_emails: %w(test@test.com test@test.com))
|
||||
end
|
||||
|
||||
after :example do
|
||||
domain_id = 1
|
||||
template_name = 'removed_company'
|
||||
described_class.enqueue(domain_id, template_name)
|
||||
end
|
||||
|
||||
it 'creates log record' do
|
||||
log_message = 'Send DomainDeleteMailer#forced email for domain test.com (#1) to test@test.com, test@test.com'
|
||||
|
||||
allow(DomainDeleteMailer).to receive(:forced).and_return(message)
|
||||
allow(message).to receive(:deliver_now)
|
||||
|
||||
expect(Rails.logger).to receive(:info).with(log_message)
|
||||
end
|
||||
|
||||
it 'sends email' do
|
||||
expect(DomainDeleteMailer).to receive(:forced).with(domain: domain,
|
||||
registrar: 'registrar',
|
||||
registrant: 'registrant',
|
||||
template_name: 'removed_company')
|
||||
.and_return(message)
|
||||
expect(message).to receive(:deliver_now)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue