Skip to content

Commit

Permalink
added liquidation email template and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Jul 18, 2023
1 parent 89d5850 commit 6d73a34
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/jobs/company_register_status_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def perform(days_interval = 14, spam_time_delay = 0.2, batch_size = 100, force_d
company_status = contact.return_company_status
contact.update!(company_register_status: company_status, checked_company_at: Time.zone.now)

ContactInformMailer.company_liquidation(contact: contact).deliver_now if company_status == Contact::LIQUIDATED

next unless [Contact::BANKRUPT, Contact::DELETED, nil].include? company_status

if force_delete
Expand Down
7 changes: 7 additions & 0 deletions app/mailers/contact_inform_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ def notify_nameserver(contact:, domain:, nameserver:)
mail(to: contact.email, subject: subject)
end

def company_liquidation(contact:)
@registrant = contact

subject = "Kas soovite oma .ee domeeni säilitada? / Do you wish to preserve your .ee registration?"
mail(to: contact.email, subject: subject)
end

private

def address_processing
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<p>Lugupeetud ettevõtte <%= @registrant.name %> esindaja,</p>

<p>Eesti Interneti Sihtasutusele (EIS) on äriregistri vahendusel teatavaks saanud, et ettevõtte <%= @registrant.name %> äriregistrikoodiga <%= @registrant.ident %> suhtes käib likvideerimismenetlus. Tuletame teile meelde, et tulenevalt .ee domeenireeglitest peab domeeni registreerijaks olema eksisteeriv era- või juriidiline isik. Seega käivitame ettevõtte likvideerimise järel sellele kuuluvate registreeringute kustutusmenetluse. Kustutusmenetluse tulemusena eemaldatakse .ee domeeninimi registrist ning vabaneb kõigile soovijatele taaskord registreerimiseks.</p>
<p>Kui soovite ettevõttele kuuluvaid registreeritud domeene ka edaspidi kasutada, soovitame teil ette valmistada registreeringute üleandmine uuele omanikule enne praeguse omaniku likvideerimist. Lähemalt leiate selle kohta infot meie kodulehelt.</p>

<p>.ee domeeni registris kuuluvad ettevõttele <%= @registrant.ident %> järgmised registreeringud:</p>
<ul>
<% @registrant.domains.each do |domain| %>
<li><%= domain.name %></li>
<% end %>
</ul>

<p>Lisaküsimuste korral võtke palun ühendust oma registripidajaga:</p>
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrant.registrar %>

<%= render 'mailers/shared/signatures/signature.et.html' %>

<hr>

<p>Dear representative of <%= @registrant.name %>,</p>

<p>The Estonian Internet Foundation (EIS) has found through the Estonian business register that the company <%= @registrant.name %> with the business registry code <%= @registrant.ident %> is in liquidation proceedings. Please note that according to the .ee domain regulation, the registrant of the domain must be an existing private or legal entity. Therefore, the registry will start the registration deletion procedure once the liquidation of the company has been finalized. After the registration deletion procedure, the domain name will be open to register again for everyone.</p>
<p>If you want to continue to use the registered domains belonging to your company, we recommend you to prepare the transfer of the registrations to the new owner before the liquidation of the current owner will be finalized. Learn more on our website.</p>

<p>The following registrations belong to the company <%= @registrant.ident %> in the .ee domain register:</p>
<ul>
<% @registrant.domains.each do |domain| %>
<li><%= domain.name %></li>
<% end %>
</ul>

<p>Should you have additional questions, please contact your registrar:</p>
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrant.registrar %>

<%= render 'mailers/shared/signatures/signature.en.html' %>
<hr>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Lugupeetud ettevõtte <%= @registrant.name %> esindaja

Eesti Interneti Sihtasutusele (EIS) on äriregistri vahendusel teatavaks saanud, et ettevõtte <%= @registrant.name %> äriregistrikoodiga <%= @registrant.ident %> suhtes käib likvideerimismenetlus. Tuletame teile meelde, et tulenevalt .ee domeenireeglitest peab domeeni registreerijaks olema eksisteeriv era- või juriidiline isik. Seega käivitame ettevõtte likvideerimise järel sellele kuuluvate registreeringute kustutusmenetluse. Kustutusmenetluse tulemusena eemaldatakse .ee domeeninimi registrist ning vabaneb kõigile soovijatele taaskord registreerimiseks.
Kui soovite ettevõttele kuuluvaid registreeritud domeene ka edaspidi kasutada, soovitame teil ette valmistada registreeringute üleandmine uuele omanikule enne praeguse omaniku likvideerimist. Lähemalt leiate selle kohta infot meie kodulehelt.

.ee domeeni registris kuuluvad ettevõttele <%= @registrant.ident %> järgmised registreeringud:

<% @registrant.domains.each do |domain| %>
<%= domain.name %>
<% end %>


Lisaküsimuste korral võtke palun ühendust oma registripidajaga:
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrant.registrar %>

<%= render 'mailers/shared/signatures/signature.et.html' %>

---

Dear representative of <%= @registrant.name %>,

The Estonian Internet Foundation (EIS) has found through the Estonian business register that the company <%= @registrant.name %> with the business registry code <%= @registrant.ident %> is in liquidation proceedings. Please note that according to the .ee domain regulation, the registrant of the domain must be an existing private or legal entity. Therefore, the registry will start the registration deletion procedure once the liquidation of the company has been finalized. After the registration deletion procedure, the domain name will be open to register again for everyone.
If you want to continue to use the registered domains belonging to your company, we recommend you to prepare the transfer of the registrations to the new owner before the liquidation of the current owner will be finalized. Learn more on our website.

The following registrations belong to the company <%= @registrant.ident %> in the .ee domain register:

<% @registrant.domains.each do |domain| %>
<%= domain.name %>
<% end %>

Should you have additional questions, please contact your registrar:
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrant.registrar %>

<%= render 'mailers/shared/signatures/signature.en.html' %>

33 changes: 33 additions & 0 deletions test/jobs/company_register_status_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,37 @@ def object.company_details(registration_number:)

assert_equal @registrant_acme.registrar.notifications.count, 2
end

def test_should_inform_contact_if_his_company_in_liquadation
original_new_method = CompanyRegister::Client.method(:new)
CompanyRegister::Client.define_singleton_method(:new) do
object = original_new_method.call
def object.company_details(registration_number:)
[Company.new('1234567', 'ACME Ltd', LIQUIDATED)]
end
object
end

ActionMailer::Base.deliveries.clear
assert_emails 0

interval_days = 5
current_time = Time.zone.now

@registrant_acme.update!(company_register_status: Contact::REGISTERED, checked_company_at: current_time - interval_days.days)
@registrant_acme.reload && @registrant_jack.reload

CompanyRegisterStatusJob.perform_now(interval_days, 0, 100, true)

@registrant_acme.reload && @registrant_jack.reload

assert_equal Contact::LIQUIDATED, @registrant_acme.company_register_status
assert_equal current_time.to_date, @registrant_acme.checked_company_at.to_date

mail = ActionMailer::Base.deliveries.first
mail_html = Nokogiri::HTML(mail.html_part.body.decoded)
text = mail_html.css('p')[1].text

assert_equal text, "Eesti Interneti Sihtasutusele (EIS) on äriregistri vahendusel teatavaks saanud, et ettevõtte #{@registrant_jack.name} äriregistrikoodiga #{@registrant_jack.ident} suhtes käib likvideerimismenetlus. Tuletame teile meelde, et tulenevalt .ee domeenireeglitest peab domeeni registreerijaks olema eksisteeriv era- või juriidiline isik. Seega käivitame ettevõtte likvideerimise järel sellele kuuluvate registreeringute kustutusmenetluse. Kustutusmenetluse tulemusena eemaldatakse .ee domeeninimi registrist ning vabaneb kõigile soovijatele taaskord registreerimiseks."
end
end
19 changes: 19 additions & 0 deletions test/mailers/contact_inform_mailer_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'test_helper'

class ContactInformMailerTest < ActionMailer::TestCase
setup do
@contact = contacts(:john)
end

def test_liquidation_email
assert_equal 'john-001', @contact.code
assert_equal '[email protected]', @contact.email

email = ContactInformMailer.company_liquidation(contact: @contact).deliver_now

assert_emails 1

assert_equal %w[[email protected]], email.to
assert_equal 'Kas soovite oma .ee domeeni säilitada? / Do you wish to preserve your .ee registration?', email.subject
end
end
2 changes: 1 addition & 1 deletion test/mailers/contact_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ def test_delivers_email_changed_email
assert_equal 'Teie domeenide kontakt epostiaadress on muutunud' \
' / Contact e-mail addresses of your domains have changed [john-001]', email.subject
end
end
end

0 comments on commit 6d73a34

Please sign in to comment.