Added pending delete expired email #2786

This commit is contained in:
Priit Tark 2015-07-28 18:07:47 +03:00
parent acb9f2ee08
commit 5883452fa2
6 changed files with 77 additions and 2 deletions

View file

@ -143,4 +143,14 @@ class DomainMailer < ApplicationMailer
subject: "#{I18n.t(:pending_delete_rejected_notification_subject, subject: "#{I18n.t(:pending_delete_rejected_notification_subject,
name: @domain.name)} [#{@domain.name}]") name: @domain.name)} [#{@domain.name}]")
end end
def pending_delete_expired_notification(domain)
@domain = domain
# no delivery off control, driggered by cron, no epp request
return if whitelist_blocked?(@domain.registrant.email)
mail(to: @domain.registrant.email,
subject: "#{I18n.t(:pending_delete_expired_notification_subject,
name: @domain.name)} [#{@domain.name}]")
end
end end

View file

@ -184,6 +184,7 @@ class Domain < ActiveRecord::Base
# rubocop: disable Metrics/AbcSize # rubocop: disable Metrics/AbcSize
# rubocop: disable Metrics/CyclomaticComplexity # rubocop: disable Metrics/CyclomaticComplexity
# rubocop: disable Metrics/PerceivedComplexity
def clean_expired_pendings def clean_expired_pendings
STDOUT << "#{Time.zone.now.utc} - Clean expired domain pendings\n" unless Rails.env.test? STDOUT << "#{Time.zone.now.utc} - Clean expired domain pendings\n" unless Rails.env.test?
@ -198,13 +199,19 @@ class Domain < ActiveRecord::Base
next next
end end
count += 1 count += 1
if domain.pending_update?
DomainMailer.pending_update_expired_notification_for_new_registrant(domain).deliver_now DomainMailer.pending_update_expired_notification_for_new_registrant(domain).deliver_now
end
if domain.pending_delete?
DomainMailer.pending_delete_expired_notification(domain).deliver_now
end
domain.clean_pendings! domain.clean_pendings!
STDOUT << "#{Time.zone.now.utc} Domain.clean_expired_pendings: ##{domain.id}\n" unless Rails.env.test? STDOUT << "#{Time.zone.now.utc} Domain.clean_expired_pendings: ##{domain.id}\n" unless Rails.env.test?
end end
STDOUT << "#{Time.zone.now.utc} - Successfully cancelled #{count} domain pendings\n" unless Rails.env.test? STDOUT << "#{Time.zone.now.utc} - Successfully cancelled #{count} domain pendings\n" unless Rails.env.test?
count count
end end
# rubocop: enable Metrics/PerceivedComplexity
# rubocop: enable Metrics/AbcSize # rubocop: enable Metrics/AbcSize
# rubocop: enable Metrics/CyclomaticComplexity # rubocop: enable Metrics/CyclomaticComplexity

View file

@ -0,0 +1,15 @@
Tere,
<br><br>
Domeeni <%= @domain.name %> kustutamise taotlust ei kinnitatud tähtaegselt registreerija <%= @domain.registrant_name %> poolt. Domeeni <%= @domain.name %> kustutamine on sellest tulenevalt tühistatud.
<br><br>
Lugupidamisega<br>
Eesti Interneti SA
<br><br>
<hr>
<br><br>
Hi,
<br><br>
Domain <%= @domain.name %> deletion cancelled.
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -0,0 +1,15 @@
Tere,
Domeeni <%= @domain.name %> kustutamise taotlust ei kinnitatud tähtaegselt registreerija <%= @domain.registrant_name %> poolt. Domeeni <%= @domain.name %> kustutamine on sellest tulenevalt tühistatud.
Lugupidamisega
Eesti Interneti SA
--------------------------------------
Hi,
Domain <%= @domain.name %> deletion cancelled.
Best Regards,
Estonian Internet Foundation

View file

@ -785,6 +785,7 @@ en:
registrant_updated_notification_for_old_registrant_subject: 'Domeeni %{name} registreerija vahetus teostatud / Registrant change of %{name} has been finished.' registrant_updated_notification_for_old_registrant_subject: 'Domeeni %{name} registreerija vahetus teostatud / Registrant change of %{name} has been finished.'
domain_pending_deleted_subject: "Kinnitustaotlus domeeni %{name} kustutamiseks .ee registrist / Application for approval for deletion of %{name}" domain_pending_deleted_subject: "Kinnitustaotlus domeeni %{name} kustutamiseks .ee registrist / Application for approval for deletion of %{name}"
pending_delete_rejected_notification_subject: "Domeeni %{name} kustutamise taotlus tagasi lükatud / %{name) deletion declined" pending_delete_rejected_notification_subject: "Domeeni %{name} kustutamise taotlus tagasi lükatud / %{name) deletion declined"
pending_delete_expired_notification_subject: "Domeeni %{name} kustutamise taotlus on tühistatud / %{name} deletion cancelled"
whois: WHOIS whois: WHOIS
login_failed_check_id_card: 'Log in failed, check ID card' login_failed_check_id_card: 'Log in failed, check ID card'
not_valid_domain_verification_title: Domain verification not available not_valid_domain_verification_title: Domain verification not available

View file

@ -249,7 +249,7 @@ describe DomainMailer do
end end
end end
describe 'email pending delete notification' do describe 'pending delete rejected notification' do
before :all do before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com') @registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, name: 'delete-pending-rejected.ee', registrant: @registrant) @domain = Fabricate(:domain, name: 'delete-pending-rejected.ee', registrant: @registrant)
@ -275,4 +275,31 @@ describe DomainMailer do
@mail.body.encoded.should =~ /deletion rejected/ @mail.body.encoded.should =~ /deletion rejected/
end end
end end
describe 'pending delete rejected notification' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, name: 'delete-pending-expired.ee', registrant: @registrant)
@domain.deliver_emails = true
@domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now
@mail = DomainMailer.pending_delete_expired_notification(@domain)
end
it 'should render email subject' do
@mail.subject.should =~ /deletion cancelled/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send confirm email to old registrant email' do
@mail.to.should == ["test@example.com"]
end
it 'should render body' do
@mail.body.encoded.should =~ /deletion cancelled/
end
end
end end