mirror of
https://github.com/internetee/registry.git
synced 2025-07-29 14:06:21 +02:00
Merge pull request #2437 from internetee/2436-fd-process-for-long-term-registrations
outzone rake task for invalid email domains
This commit is contained in:
commit
e4740ffceb
5 changed files with 140 additions and 8 deletions
|
@ -10,6 +10,8 @@ class EisBilling::EInvoiceResponseController < EisBilling::BaseController
|
|||
|
||||
def mark_e_invoice_sent_at(invoice_number)
|
||||
invoice = Invoice.find_by(number: invoice_number)
|
||||
invoice = Invoice.find_by(number: invoice_number['invoice_number']) if invoice.nil?
|
||||
|
||||
invoice.update(e_invoice_sent_at: Time.zone.now)
|
||||
end
|
||||
end
|
||||
|
|
21
app/jobs/outzone_invalid_email_domains_job.rb
Normal file
21
app/jobs/outzone_invalid_email_domains_job.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
class OutzoneInvalidEmailDomainsJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform
|
||||
domains = Domain.where("force_delete_data->'template_name' = ?", 'invalid_email')
|
||||
.where(outzone_at: nil)
|
||||
.where('Date(force_delete_start) <= ?', Time.zone.now)
|
||||
|
||||
domains.each do |domain|
|
||||
outzone(domain)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def outzone(domain)
|
||||
domain.outzone_at = domain.force_delete_start + Domain.expire_warning_period
|
||||
domain.delete_date = domain.outzone_at + Domain.redemption_grace_period
|
||||
domain.save
|
||||
end
|
||||
end
|
7
lib/tasks/outzone_invalid_email_domains.rake
Normal file
7
lib/tasks/outzone_invalid_email_domains.rake
Normal file
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
desc 'Rake task run outzone setter task for force deleted domains by invalid emails'
|
||||
|
||||
task outzone_invalid_email_domains: :environment do
|
||||
OutzoneInvalidEmailDomainsJob.perform_later
|
||||
end
|
|
@ -1,18 +1,92 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BaseTest < ActiveSupport::TestCase
|
||||
def test_hold_domains_force_delete_email
|
||||
domain = domains(:shop)
|
||||
domain.update!(statuses: [DomainStatus::SERVER_HOLD])
|
||||
domain.update!(expire_time: Time.zone.now + 1.year)
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
@domain_airport = domains(:airport)
|
||||
end
|
||||
|
||||
registrant = domain.registrant
|
||||
registrant.update!(email: "#{registrant.email.split('@').first}@#{domain.name}")
|
||||
def test_hold_domains_force_delete_email
|
||||
@domain.update!(statuses: [DomainStatus::SERVER_HOLD])
|
||||
@domain.update!(expire_time: Time.zone.now + 1.year)
|
||||
|
||||
registrant = @domain.registrant
|
||||
registrant.update!(email: "#{registrant.email.split('@').first}@#{@domain.name}")
|
||||
|
||||
Domains::ForceDeleteEmail::Base.run(email: registrant.email)
|
||||
|
||||
domain.reload
|
||||
@domain.reload
|
||||
|
||||
assert_not domain.force_delete_scheduled?
|
||||
assert_not @domain.force_delete_scheduled?
|
||||
end
|
||||
|
||||
def test_more_that_year_until_valid_to_date
|
||||
refute @domain_airport.force_delete_scheduled?
|
||||
@domain_airport.update!(valid_to: Time.zone.now + 3.years + 1.month + 1.day)
|
||||
@domain_airport.reload
|
||||
prepare_contact
|
||||
|
||||
contact = @domain_airport.admin_contacts.first
|
||||
|
||||
Domains::ForceDeleteEmail::Base.run(email: contact.email)
|
||||
@domain_airport.reload
|
||||
|
||||
assert @domain_airport.force_delete_scheduled?
|
||||
assert @domain_airport.valid_to > Time.zone.now + 1.year
|
||||
assert_equal @domain_airport.force_delete_start.to_date, (Time.zone.now + 1.month + 1.day).to_date
|
||||
assert_equal @domain_airport.force_delete_date, (@domain_airport.force_delete_start +
|
||||
Setting.expire_warning_period.days +
|
||||
Setting.redemption_grace_period.days).to_date
|
||||
end
|
||||
|
||||
def test_more_that_year_until_valid_to_date_but_month_is_previous
|
||||
refute @domain_airport.force_delete_scheduled?
|
||||
@domain_airport.update!(valid_to: Time.zone.now + 3.years - 1.month - 4.days)
|
||||
@domain_airport.reload
|
||||
prepare_contact
|
||||
|
||||
contact = @domain_airport.admin_contacts.first
|
||||
|
||||
Domains::ForceDeleteEmail::Base.run(email: contact.email)
|
||||
@domain_airport.reload
|
||||
|
||||
assert @domain_airport.force_delete_scheduled?
|
||||
assert @domain_airport.valid_to > Time.zone.now + 1.year
|
||||
assert_equal @domain_airport.force_delete_start.to_date, (Time.zone.now + 1.year - 1.month - 4.days).to_date
|
||||
assert_equal @domain_airport.force_delete_date, (@domain_airport.force_delete_start +
|
||||
Setting.expire_warning_period.days +
|
||||
Setting.redemption_grace_period.days).to_date
|
||||
end
|
||||
|
||||
def test_should_send_poll_message_about_45_days_to_registrar
|
||||
refute @domain_airport.force_delete_scheduled?
|
||||
@domain_airport.update!(valid_to: Time.zone.now + 3.years - 1.month - 4.days)
|
||||
@domain_airport.reload
|
||||
prepare_contact
|
||||
|
||||
contact = @domain_airport.admin_contacts.first
|
||||
|
||||
assert_difference -> { @domain_airport.registrar.notifications.count } do
|
||||
Domains::ForceDeleteEmail::Base.run(email: contact.email)
|
||||
end
|
||||
|
||||
@domain_airport.reload
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def prepare_contact
|
||||
assert_not @domain_airport.force_delete_scheduled?
|
||||
email = '~@internet.ee'
|
||||
|
||||
contact = @domain_airport.admin_contacts.first
|
||||
contact.update_attribute(:email, email)
|
||||
(ValidationEvent::VALID_EVENTS_COUNT_THRESHOLD).times do
|
||||
contact.verify_email
|
||||
end
|
||||
contact.reload
|
||||
|
||||
refute contact.validation_events.last.success?
|
||||
assert contact.need_to_start_force_delete?
|
||||
end
|
||||
end
|
||||
|
|
28
test/jobs/outzone_invalid_email_domains_job_test.rb
Normal file
28
test/jobs/outzone_invalid_email_domains_job_test.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require 'test_helper'
|
||||
|
||||
class OutzoneInvalidEmailDomainsJobTest < ActiveJob::TestCase
|
||||
include ActionMailer::TestHelper
|
||||
|
||||
setup do
|
||||
ActionMailer::Base.deliveries.clear
|
||||
@domain = domains(:airport)
|
||||
end
|
||||
|
||||
def test_set_outzone_datetime_for_fd_domains_by_invalid_emails
|
||||
@domain.update(valid_to: Time.zone.now + 3.years)
|
||||
@domain.reload
|
||||
|
||||
assert_nil @domain.outzone_at
|
||||
|
||||
@domain.schedule_force_delete(type: :soft)
|
||||
@domain.force_delete_data = {"template_name"=>"invalid_email", "force_delete_type"=>"soft"}
|
||||
@domain.save
|
||||
|
||||
OutzoneInvalidEmailDomainsJob.perform_now
|
||||
@domain.reload
|
||||
|
||||
assert @domain.force_delete_scheduled?
|
||||
assert @domain.valid_to > Time.zone.now + 1.year
|
||||
assert_equal @domain.outzone_at, @domain.force_delete_start + Setting.expire_warning_period.day
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue