mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 12:08:27 +02:00
Merge remote-tracking branch 'origin/registry-186' into registry-186
This commit is contained in:
commit
97426e001b
14 changed files with 154 additions and 56 deletions
|
@ -4,6 +4,7 @@ class DomainExpirationEmailJob < Que::Job
|
|||
|
||||
return if domain.registered?
|
||||
|
||||
DomainMailer.expiration(domain: domain).deliver!
|
||||
DomainMailer.expiration(domain: domain).deliver
|
||||
destroy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,8 +31,13 @@ class RegistrantChangeMailer < ApplicationMailer
|
|||
mail(to: domain.new_registrant_email, subject: subject)
|
||||
end
|
||||
|
||||
def pending_update_expired_notification_for_new_registrant(params)
|
||||
compose_from(params)
|
||||
def expired(domain:, registrar:, registrant:)
|
||||
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
||||
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
|
||||
@registrant = RegistrantPresenter.new(registrant: registrant, view: view_context)
|
||||
|
||||
subject = default_i18n_subject(domain_name: domain.name)
|
||||
mail(to: domain.new_registrant_email, subject: subject)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -16,7 +16,8 @@ class DomainCron
|
|||
end
|
||||
count += 1
|
||||
if domain.pending_update?
|
||||
DomainMailer.pending_update_expired_notification_for_new_registrant(domain.id).deliver
|
||||
RegistrantChangeMailer.expired(domain: domain, registrar: domain.registrar, registrant: domain.registrant)
|
||||
.deliver
|
||||
end
|
||||
if domain.pending_delete? || domain.pending_delete_confirmation?
|
||||
DomainMailer.pending_delete_expired_notification(domain.id, true).deliver
|
||||
|
|
|
@ -6,13 +6,6 @@ class DomainMailModel
|
|||
@params = {errors: [], deliver_emails: domain.deliver_emails, id: domain.id}
|
||||
end
|
||||
|
||||
def pending_update_expired_notification_for_new_registrant
|
||||
registrant_pending
|
||||
subject(:pending_update_expired_notification_for_new_registrant_subject)
|
||||
domain_info
|
||||
compose
|
||||
end
|
||||
|
||||
def pending_delete_rejected_notification
|
||||
registrant
|
||||
subject(:pending_delete_rejected_notification_subject)
|
||||
|
|
|
@ -4,7 +4,7 @@ Domeeni <%= @domain.name %> registreerija <%= @registrant.name %> ei kinnitanud
|
|||
<br><br>
|
||||
Küsimuste korral palun võtke ühendust oma registripidajaga:
|
||||
|
||||
<%= render 'registrar.et.html', registrar: @registrar %>
|
||||
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
|
||||
|
||||
<br><br>
|
||||
Lugupidamisega<br>
|
||||
|
@ -18,7 +18,7 @@ Domain registrant change request has been expired for the domain <%= @domain.nam
|
|||
<br><br>
|
||||
Please contact to your registrar if you have any questions:
|
||||
|
||||
<%= render 'registrar.en.html', registrar: @registrar %>
|
||||
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
|
||||
|
||||
<br><br>
|
||||
Best Regards,<br>
|
|
@ -4,7 +4,7 @@ Domeeni <%= @domain.name %> registreerija <%= @registrant.name %> ei kinnitanud
|
|||
|
||||
Küsimuste korral palun võtke ühendust oma registripidajaga:
|
||||
|
||||
<%= render 'registrar.et.text', registrar: @registrar %>
|
||||
<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
|
||||
|
||||
Lugupidamisega
|
||||
Eesti Interneti Sihtasutus
|
||||
|
@ -17,7 +17,7 @@ Domain registrant change request has been expired for the domain <%= @domain.nam
|
|||
|
||||
Please contact to your registrar if you have any questions:
|
||||
|
||||
<%= render 'registrar.en.text', registrar: @registrar %>
|
||||
<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
|
||||
|
||||
Best Regards,
|
||||
Estonian Internet Foundation
|
|
@ -796,7 +796,6 @@ en:
|
|||
unimplemented_object_service: 'Unimplemented object service'
|
||||
contact_email_update_subject: 'Teie domeenide kontakt epostiaadress on muutunud / Contact e-mail addresses of your domains have changed'
|
||||
object_status_prohibits_operation: 'Object status prohibits operation'
|
||||
pending_update_expired_notification_for_new_registrant_subject: "Domeeni %{name} registreerija vahetuse taotlus on tühistatud / %{name} registrant change cancelled"
|
||||
registrant_updated_notification_for_new_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.'
|
||||
pending_delete_rejected_notification_subject: "Domeeni %{name} kustutamise taotlus tagasi lükatud / %{name} deletion declined"
|
||||
|
|
|
@ -6,3 +6,5 @@ en:
|
|||
subject: Domeeni %{domain_name} registreerija vahetus protseduur on algatatud / %{domain_name} registrant change
|
||||
rejected:
|
||||
subject: Domeeni %{domain_name} registreerija vahetuse taotlus tagasi lükatud / %{domain_name} registrant change declined
|
||||
expired:
|
||||
subject: Domeeni %{domain_name} registreerija vahetuse taotlus on tühistatud / %{domain_name} registrant change cancelled
|
||||
|
|
|
@ -17,7 +17,7 @@ RSpec.describe DomainExpirationEmailJob do
|
|||
|
||||
it 'sends email notification' do
|
||||
expect(DomainMailer).to receive(:expiration).with(domain: domain).and_return(message)
|
||||
expect(message).to receive(:deliver!)
|
||||
expect(message).to receive(:deliver)
|
||||
described_class.enqueue(domain_id: 1)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -104,8 +104,8 @@ RSpec.describe RegistrantChangeMailer do
|
|||
let(:registrant_presenter) { instance_spy(RegistrantPresenter) }
|
||||
|
||||
subject(:message) { described_class.rejected(domain: domain,
|
||||
registrar: registrar,
|
||||
registrant: registrant)
|
||||
registrar: registrar,
|
||||
registrant: registrant)
|
||||
}
|
||||
|
||||
before :example do
|
||||
|
@ -133,4 +133,44 @@ RSpec.describe RegistrantChangeMailer do
|
|||
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#expired' do
|
||||
let(:domain) { instance_spy(Domain, name: 'test.com', new_registrant_email: 'new.registrant@test.com') }
|
||||
let(:registrar) { instance_spy(Registrar) }
|
||||
let(:registrant) { instance_spy(Registrant) }
|
||||
|
||||
let(:domain_presenter) { instance_spy(DomainPresenter) }
|
||||
let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
|
||||
let(:registrant_presenter) { instance_spy(RegistrantPresenter) }
|
||||
|
||||
subject(:message) { described_class.expired(domain: domain,
|
||||
registrar: registrar,
|
||||
registrant: registrant)
|
||||
}
|
||||
|
||||
before :example do
|
||||
expect(DomainPresenter).to receive(:new).and_return(domain_presenter)
|
||||
expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter)
|
||||
expect(RegistrantPresenter).to receive(:new).and_return(registrant_presenter)
|
||||
end
|
||||
|
||||
it 'has sender' do
|
||||
expect(message.from).to eq(['noreply@internet.ee'])
|
||||
end
|
||||
|
||||
it 'has new registrant\s email as a recipient' do
|
||||
expect(message.to).to match_array(['new.registrant@test.com'])
|
||||
end
|
||||
|
||||
it 'has subject' do
|
||||
subject = 'Domeeni test.com registreerija vahetuse taotlus on tühistatud' \
|
||||
' / test.com registrant change cancelled'
|
||||
|
||||
expect(message.subject).to eq(subject)
|
||||
end
|
||||
|
||||
it 'sends message' do
|
||||
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,25 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe Domain do
|
||||
before :example do
|
||||
Setting.ds_algorithm = 2
|
||||
Setting.ds_data_allowed = true
|
||||
Setting.ds_data_with_key_allowed = true
|
||||
Setting.key_data_allowed = true
|
||||
|
||||
Setting.dnskeys_min_count = 0
|
||||
Setting.dnskeys_max_count = 9
|
||||
Setting.ns_min_count = 2
|
||||
Setting.ns_max_count = 11
|
||||
|
||||
Setting.transfer_wait_time = 0
|
||||
|
||||
Setting.admin_contacts_min_count = 1
|
||||
Setting.admin_contacts_max_count = 10
|
||||
Setting.tech_contacts_min_count = 0
|
||||
Setting.tech_contacts_max_count = 10
|
||||
|
||||
Setting.client_side_status_editing_enabled = true
|
||||
|
||||
Fabricate(:zonefile_setting, origin: 'ee')
|
||||
Fabricate(:zonefile_setting, origin: 'pri.ee')
|
||||
Fabricate(:zonefile_setting, origin: 'med.ee')
|
||||
|
@ -157,24 +176,11 @@ RSpec.describe Domain do
|
|||
end
|
||||
|
||||
it 'should start redemption grace period' do
|
||||
DomainCron.start_redemption_grace_period
|
||||
@domain.reload
|
||||
@domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false
|
||||
|
||||
@domain.outzone_at = Time.zone.now
|
||||
@domain.statuses << DomainStatus::SERVER_MANUAL_INZONE # this prohibits server_hold
|
||||
@domain.save
|
||||
domain = Fabricate(:domain)
|
||||
|
||||
DomainCron.start_redemption_grace_period
|
||||
@domain.reload
|
||||
@domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false
|
||||
|
||||
@domain.statuses = []
|
||||
@domain.save
|
||||
|
||||
DomainCron.start_redemption_grace_period
|
||||
@domain.reload
|
||||
@domain.statuses.include?(DomainStatus::SERVER_HOLD).should == true
|
||||
domain.reload
|
||||
domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false
|
||||
end
|
||||
|
||||
it 'should set force delete time' do
|
||||
|
@ -329,27 +335,6 @@ RSpec.describe Domain do
|
|||
end
|
||||
end
|
||||
|
||||
it 'should start redemption grace period' do
|
||||
DomainCron.start_redemption_grace_period
|
||||
@domain.reload
|
||||
@domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false
|
||||
|
||||
@domain.outzone_at = Time.zone.now
|
||||
@domain.statuses << DomainStatus::SERVER_MANUAL_INZONE # this prohibits server_hold
|
||||
@domain.save
|
||||
|
||||
DomainCron.start_redemption_grace_period
|
||||
@domain.reload
|
||||
@domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false
|
||||
|
||||
@domain.statuses = []
|
||||
@domain.save
|
||||
|
||||
DomainCron.start_redemption_grace_period
|
||||
@domain.reload
|
||||
@domain.statuses.include?(DomainStatus::SERVER_HOLD).should == true
|
||||
end
|
||||
|
||||
it 'should set pending update' do
|
||||
@domain.statuses = DomainStatus::OK # restore
|
||||
@domain.save
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
require 'rails_helper'
|
||||
require_relative 'expired_shared'
|
||||
|
||||
RSpec.describe 'mailers/registrant_change_mailer/expired.html.erb' do
|
||||
before :example do
|
||||
stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian'
|
||||
stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english'
|
||||
end
|
||||
|
||||
include_examples 'registrant change mailer expired'
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
require 'rails_helper'
|
||||
require_relative 'expired_shared'
|
||||
|
||||
RSpec.describe 'mailers/registrant_change_mailer/expired.text.erb' do
|
||||
before :example do
|
||||
stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian'
|
||||
stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english'
|
||||
end
|
||||
|
||||
include_examples 'registrant change mailer expired'
|
||||
end
|
|
@ -0,0 +1,50 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.shared_examples 'registrant change mailer expired' do
|
||||
let(:domain) { instance_spy(DomainPresenter) }
|
||||
let(:registrar) { instance_spy(RegistrarPresenter) }
|
||||
let(:registrant) { instance_spy(RegistrantPresenter) }
|
||||
let(:lang_count) { 2 }
|
||||
|
||||
before :example do
|
||||
assign(:domain, domain)
|
||||
assign(:registrar, registrar)
|
||||
assign(:registrant, registrant)
|
||||
end
|
||||
|
||||
it 'has registrar info in estonian' do
|
||||
render
|
||||
expect(rendered).to have_text('test registrar estonian')
|
||||
end
|
||||
|
||||
it 'has registrar info in english' do
|
||||
render
|
||||
expect(rendered).to have_text('test registrar english')
|
||||
end
|
||||
|
||||
domain_attributes = %i(
|
||||
name
|
||||
)
|
||||
|
||||
domain_attributes.each do |attr_name|
|
||||
it "has domain #{attr_name}" do
|
||||
mention_count = 3
|
||||
expect(domain).to receive(attr_name).exactly(mention_count).times.and_return("test domain #{attr_name}")
|
||||
render
|
||||
expect(rendered).to have_text("test domain #{attr_name}", count: mention_count)
|
||||
end
|
||||
end
|
||||
|
||||
registrant_attributes = %i(
|
||||
name
|
||||
)
|
||||
|
||||
registrant_attributes.each do |attr_name|
|
||||
it "has registrant #{attr_name}" do
|
||||
mention_count = 1
|
||||
expect(registrant).to receive(attr_name).exactly(mention_count).times.and_return("test registrant #{attr_name}")
|
||||
render
|
||||
expect(rendered).to have_text("test registrant #{attr_name}", count: mention_count)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue