mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
parent
bfc0c0b74f
commit
876c010435
17 changed files with 156 additions and 273 deletions
|
@ -7,6 +7,7 @@ class DomainUpdateConfirmJob < Que::Job
|
||||||
domain.is_admin = true
|
domain.is_admin = true
|
||||||
case action
|
case action
|
||||||
when RegistrantVerification::CONFIRMED
|
when RegistrantVerification::CONFIRMED
|
||||||
|
old_registrant = domain.registrant
|
||||||
domain.poll_message!(:poll_pending_update_confirmed_by_registrant)
|
domain.poll_message!(:poll_pending_update_confirmed_by_registrant)
|
||||||
raise_errors!(domain)
|
raise_errors!(domain)
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@ class DomainUpdateConfirmJob < Que::Job
|
||||||
|
|
||||||
domain.clean_pendings!
|
domain.clean_pendings!
|
||||||
raise_errors!(domain)
|
raise_errors!(domain)
|
||||||
|
RegistrantChange.new(domain: domain, old_registrant: old_registrant).confirm
|
||||||
when RegistrantVerification::REJECTED
|
when RegistrantVerification::REJECTED
|
||||||
RegistrantChangeMailer.rejected(domain: domain,
|
RegistrantChangeMailer.rejected(domain: domain,
|
||||||
registrar: domain.registrar,
|
registrar: domain.registrar,
|
||||||
|
|
|
@ -1,37 +1,6 @@
|
||||||
class DomainMailer < ApplicationMailer
|
class DomainMailer < ApplicationMailer
|
||||||
include Que::Mailer
|
include Que::Mailer
|
||||||
|
|
||||||
def registrant_updated_notification_for_new_registrant(domain_id, old_registrant_id, new_registrant_id, should_deliver)
|
|
||||||
@domain = Domain.find_by(id: domain_id)
|
|
||||||
return unless @domain
|
|
||||||
return if delivery_off?(@domain, should_deliver)
|
|
||||||
|
|
||||||
@old_registrant = Registrant.find(old_registrant_id)
|
|
||||||
@new_registrant = Registrant.find(new_registrant_id)
|
|
||||||
@address_processing = Contact.address_processing?
|
|
||||||
|
|
||||||
return if whitelist_blocked?(@new_registrant.email)
|
|
||||||
mail(to: format(@new_registrant.email),
|
|
||||||
subject: "#{I18n.t(:registrant_updated_notification_for_new_registrant_subject,
|
|
||||||
name: @domain.name)} [#{@domain.name}]")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def registrant_updated_notification_for_old_registrant(domain_id, old_registrant_id, new_registrant_id, should_deliver)
|
|
||||||
@domain = Domain.find_by(id: domain_id)
|
|
||||||
return unless @domain
|
|
||||||
return if delivery_off?(@domain, should_deliver)
|
|
||||||
|
|
||||||
@old_registrant = Registrant.find(old_registrant_id)
|
|
||||||
@new_registrant = Registrant.find(new_registrant_id)
|
|
||||||
@address_processing = Contact.address_processing?
|
|
||||||
|
|
||||||
return if whitelist_blocked?(@old_registrant.email)
|
|
||||||
mail(to: format(@old_registrant.email),
|
|
||||||
subject: "#{I18n.t(:registrant_updated_notification_for_old_registrant_subject,
|
|
||||||
name: @domain.name)} [#{@domain.name}]")
|
|
||||||
end
|
|
||||||
|
|
||||||
def pending_delete_rejected_notification(domain_id, should_deliver)
|
def pending_delete_rejected_notification(domain_id, should_deliver)
|
||||||
@domain = Domain.find_by(id: domain_id)
|
@domain = Domain.find_by(id: domain_id)
|
||||||
return unless @domain
|
return unless @domain
|
||||||
|
|
|
@ -21,6 +21,14 @@ class RegistrantChangeMailer < ApplicationMailer
|
||||||
mail(to: new_registrant.email, subject: subject)
|
mail(to: new_registrant.email, subject: subject)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def confirmed(domain:, old_registrant:)
|
||||||
|
@domain = domain
|
||||||
|
recipients = [domain.registrant_email, old_registrant.email]
|
||||||
|
subject = default_i18n_subject(domain_name: domain.name)
|
||||||
|
|
||||||
|
mail(to: recipients, subject: subject)
|
||||||
|
end
|
||||||
|
|
||||||
def rejected(domain:, registrar:, registrant:)
|
def rejected(domain:, registrar:, registrant:)
|
||||||
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
||||||
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
|
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
|
||||||
|
|
|
@ -521,9 +521,7 @@ class Epp::Domain < Domain
|
||||||
preclean_pendings
|
preclean_pendings
|
||||||
user = ApiUser.find(pending_json['current_user_id'])
|
user = ApiUser.find(pending_json['current_user_id'])
|
||||||
frame = Nokogiri::XML(pending_json['frame'])
|
frame = Nokogiri::XML(pending_json['frame'])
|
||||||
old_registrant_id = registrant_id
|
|
||||||
|
|
||||||
self.deliver_emails = true # turn on email delivery
|
|
||||||
self.statuses.delete(DomainStatus::PENDING_UPDATE)
|
self.statuses.delete(DomainStatus::PENDING_UPDATE)
|
||||||
self.upid = user.registrar.id if user.registrar
|
self.upid = user.registrar.id if user.registrar
|
||||||
self.up_date = Time.zone.now
|
self.up_date = Time.zone.now
|
||||||
|
@ -531,11 +529,9 @@ class Epp::Domain < Domain
|
||||||
return unless update(frame, user, false)
|
return unless update(frame, user, false)
|
||||||
clean_pendings!
|
clean_pendings!
|
||||||
|
|
||||||
save! # for notification if everything fails
|
save!
|
||||||
|
|
||||||
WhoisRecord.find_by(domain_id: id).save # need to reload model
|
WhoisRecord.find_by(domain_id: id).save # need to reload model
|
||||||
DomainMailer.registrant_updated_notification_for_old_registrant(id, old_registrant_id, registrant_id, true).deliver
|
|
||||||
DomainMailer.registrant_updated_notification_for_new_registrant(id, old_registrant_id, registrant_id, true).deliver
|
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
19
app/services/registrant_change.rb
Normal file
19
app/services/registrant_change.rb
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
class RegistrantChange
|
||||||
|
def initialize(domain:, old_registrant:)
|
||||||
|
@domain = domain
|
||||||
|
@old_registrant = old_registrant
|
||||||
|
end
|
||||||
|
|
||||||
|
def confirm
|
||||||
|
notify_registrant
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def notify_registrant
|
||||||
|
RegistrantChangeMailer.confirmed(domain: domain, old_registrant: old_registrant).deliver_now
|
||||||
|
end
|
||||||
|
|
||||||
|
attr_reader :domain
|
||||||
|
attr_reader :old_registrant
|
||||||
|
end
|
|
@ -1,43 +0,0 @@
|
||||||
Tere
|
|
||||||
<br><br>
|
|
||||||
Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
|
|
||||||
<br><br>
|
|
||||||
Uue registreerija andmed:<br>
|
|
||||||
Nimi: <%= @new_registrant.name %><br>
|
|
||||||
<% if @new_registrant.priv? %>
|
|
||||||
Isikukood: <%= @new_registrant.ident %><br>
|
|
||||||
<% else %>
|
|
||||||
Äriregistrikood: <%= @new_registrant.ident %><br>
|
|
||||||
<% end %>
|
|
||||||
Epost: <%= @new_registrant.email %><br>
|
|
||||||
<% if @address_processing -%>
|
|
||||||
Tänav: <%= @new_registrant.street %><br>
|
|
||||||
Linn: <%= @new_registrant.city %><br>
|
|
||||||
Riik: <%= @new_registrant.country.name %>
|
|
||||||
<% end -%>
|
|
||||||
<br><br>
|
|
||||||
Lugupidamisega<br>
|
|
||||||
Eesti Interneti Sihtasutus
|
|
||||||
<br><br>
|
|
||||||
<hr>
|
|
||||||
<br><br>
|
|
||||||
Hi,
|
|
||||||
<br><br>
|
|
||||||
Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated.
|
|
||||||
<br><br>
|
|
||||||
New registrant:<br>
|
|
||||||
Name: <%= @new_registrant.name %><br>
|
|
||||||
<% if @new_registrant.priv? %>
|
|
||||||
Personal code: <%= @new_registrant.ident %><br>
|
|
||||||
<% else %>
|
|
||||||
Business Registry code: <%= @new_registrant.ident %><br>
|
|
||||||
<% end %>
|
|
||||||
E-mail: <%= @new_registrant.email %><br>
|
|
||||||
<% if @address_processing -%>
|
|
||||||
Street: <%= @new_registrant.street %><br>
|
|
||||||
City: <%= @new_registrant.city %><br>
|
|
||||||
Country: <%= @new_registrant.country.name %>
|
|
||||||
<% end -%>
|
|
||||||
<br><br>
|
|
||||||
Best Regards,<br>
|
|
||||||
Estonian Internet Foundation
|
|
|
@ -1,45 +0,0 @@
|
||||||
Tere
|
|
||||||
|
|
||||||
Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
|
|
||||||
|
|
||||||
Uue registreerija andmed:
|
|
||||||
Nimi: <%= @new_registrant.name %>
|
|
||||||
|
|
||||||
<% if @new_registrant.priv? %>
|
|
||||||
Isikukood: <%= @new_registrant.ident %>
|
|
||||||
<% else %>
|
|
||||||
Äriregistrikood: <%= @new_registrant.ident %>
|
|
||||||
<% end %>
|
|
||||||
Epost: <%= @new_registrant.email %>
|
|
||||||
<% if @address_processing -%>
|
|
||||||
Tänav: <%= @new_registrant.street %>
|
|
||||||
Linn: <%= @new_registrant.city %>
|
|
||||||
Riik: <%= @new_registrant.country.name %>
|
|
||||||
<% end -%>
|
|
||||||
|
|
||||||
Lugupidamisega
|
|
||||||
Eesti Interneti Sihtasutus
|
|
||||||
|
|
||||||
--------------------------------------
|
|
||||||
|
|
||||||
Hi,
|
|
||||||
|
|
||||||
Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated.
|
|
||||||
|
|
||||||
New registrant:
|
|
||||||
Name: <%= @new_registrant.name %>
|
|
||||||
|
|
||||||
<% if @new_registrant.priv? %>
|
|
||||||
Personal code: <%= @new_registrant.ident %>
|
|
||||||
<% else %>
|
|
||||||
Business Registry code: <%= @new_registrant.ident %>
|
|
||||||
<% end %>
|
|
||||||
E-mail: <%= @new_registrant.email %>
|
|
||||||
<% if @address_processing -%>
|
|
||||||
Street: <%= @new_registrant.street %>
|
|
||||||
City: <%= @new_registrant.city %>
|
|
||||||
Country: <%= @new_registrant.country.name %>
|
|
||||||
<% end -%>
|
|
||||||
|
|
||||||
Best Regards,
|
|
||||||
Estonian Internet Foundation
|
|
|
@ -1,43 +0,0 @@
|
||||||
Tere
|
|
||||||
<br><br>
|
|
||||||
Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
|
|
||||||
<br><br>
|
|
||||||
Uue registreerija andmed:<br>
|
|
||||||
Nimi: <%= @new_registrant.name %><br>
|
|
||||||
<% if @new_registrant.priv? %>
|
|
||||||
Isikukood: <%= @new_registrant.ident %><br>
|
|
||||||
<% else %>
|
|
||||||
Äriregistrikood: <%= @new_registrant.ident %><br>
|
|
||||||
<% end %>
|
|
||||||
Epost: <%= @new_registrant.email %><br>
|
|
||||||
<% if @address_processing -%>
|
|
||||||
Tänav: <%= @new_registrant.street %><br>
|
|
||||||
Linn: <%= @new_registrant.city %><br>
|
|
||||||
Riik: <%= @new_registrant.country.name %>
|
|
||||||
<% end -%>
|
|
||||||
<br><br>
|
|
||||||
Lugupidamisega<br>
|
|
||||||
Eesti Interneti Sihtasutus
|
|
||||||
<br><br>
|
|
||||||
<hr>
|
|
||||||
<br><br>
|
|
||||||
Hi,
|
|
||||||
<br><br>
|
|
||||||
Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated.
|
|
||||||
<br><br>
|
|
||||||
New registrant:<br>
|
|
||||||
Name: <%= @new_registrant.name %><br>
|
|
||||||
<% if @new_registrant.priv? %>
|
|
||||||
Personal code: <%= @new_registrant.ident %><br>
|
|
||||||
<% else %>
|
|
||||||
Business Registry code: <%= @new_registrant.ident %><br>
|
|
||||||
<% end %>
|
|
||||||
E-mail: <%= @new_registrant.email %><br>
|
|
||||||
<% if @address_processing -%>
|
|
||||||
Street: <%= @new_registrant.street %><br>
|
|
||||||
City: <%= @new_registrant.city %><br>
|
|
||||||
Country: <%= @new_registrant.country.name %>
|
|
||||||
<% end -%>
|
|
||||||
<br><br>
|
|
||||||
Best Regards,<br>
|
|
||||||
Estonian Internet Foundation
|
|
|
@ -1,45 +0,0 @@
|
||||||
Tere
|
|
||||||
|
|
||||||
Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
|
|
||||||
|
|
||||||
Uue registreerija andmed:
|
|
||||||
Nimi: <%= @new_registrant.name %>
|
|
||||||
|
|
||||||
<% if @new_registrant.priv? %>
|
|
||||||
Isikukood: <%= @new_registrant.ident %>
|
|
||||||
<% else %>
|
|
||||||
Äriregistrikood: <%= @new_registrant.ident %>
|
|
||||||
<% end %>
|
|
||||||
Epost: <%= @new_registrant.email %>
|
|
||||||
<% if @address_processing -%>
|
|
||||||
Tänav: <%= @new_registrant.street %>
|
|
||||||
Linn: <%= @new_registrant.city %>
|
|
||||||
Riik: <%= @new_registrant.country.name %>
|
|
||||||
<% end -%>
|
|
||||||
|
|
||||||
Lugupidamisega
|
|
||||||
Eesti Interneti Sihtasutus
|
|
||||||
|
|
||||||
--------------------------------------
|
|
||||||
|
|
||||||
Hi,
|
|
||||||
|
|
||||||
Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated.
|
|
||||||
|
|
||||||
New registrant:
|
|
||||||
Name: <%= @new_registrant.name %>
|
|
||||||
|
|
||||||
<% if @new_registrant.priv? %>
|
|
||||||
Personal code: <%= @new_registrant.ident %>
|
|
||||||
<% else %>
|
|
||||||
Business Registry code: <%= @new_registrant.ident %>
|
|
||||||
<% end %>
|
|
||||||
E-mail: <%= @new_registrant.email %>
|
|
||||||
<% if @address_processing -%>
|
|
||||||
Street: <%= @new_registrant.street %>
|
|
||||||
City: <%= @new_registrant.city %>
|
|
||||||
Country: <%= @new_registrant.country.name %>
|
|
||||||
<% end -%>
|
|
||||||
|
|
||||||
Best Regards,
|
|
||||||
Estonian Internet Foundation
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
<%
|
||||||
|
domain = DomainPresenter.new(domain: @domain, view: self)
|
||||||
|
new_registrant = RegistrantPresenter.new(registrant: @domain.registrant, view: self)
|
||||||
|
%>
|
||||||
|
Tere
|
||||||
|
<br><br>
|
||||||
|
Domeeni <%= domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
|
||||||
|
<br><br>
|
||||||
|
Uue registreerija andmed:<br>
|
||||||
|
<%= render 'mailers/shared/registrant/registrant.et.html', registrant: new_registrant %>
|
||||||
|
<br><br>
|
||||||
|
Lugupidamisega<br>
|
||||||
|
Eesti Interneti Sihtasutus
|
||||||
|
<br><br>
|
||||||
|
<hr>
|
||||||
|
<br><br>
|
||||||
|
Hi,
|
||||||
|
<br><br>
|
||||||
|
Process for changing registrant of the domain <%= domain.name %> has been approved and the data in the registry is updated.
|
||||||
|
<br><br>
|
||||||
|
New registrant:<br>
|
||||||
|
<%= render 'mailers/shared/registrant/registrant.en.html', registrant: new_registrant %>
|
||||||
|
<br><br>
|
||||||
|
Best Regards,<br>
|
||||||
|
Estonian Internet Foundation
|
|
@ -0,0 +1,25 @@
|
||||||
|
<%
|
||||||
|
domain = DomainPresenter.new(domain: @domain, view: self)
|
||||||
|
new_registrant = RegistrantPresenter.new(registrant: @domain.registrant, view: self)
|
||||||
|
%>
|
||||||
|
Tere
|
||||||
|
|
||||||
|
Domeeni <%= domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
|
||||||
|
|
||||||
|
Uue registreerija andmed:
|
||||||
|
<%= render 'mailers/shared/registrant/registrant.et.text', registrant: new_registrant %>
|
||||||
|
|
||||||
|
Lugupidamisega
|
||||||
|
Eesti Interneti Sihtasutus
|
||||||
|
|
||||||
|
--------------------------------------
|
||||||
|
|
||||||
|
Hi,
|
||||||
|
|
||||||
|
Process for changing registrant of the domain <%= domain.name %> has been approved and the data in the registry is updated.
|
||||||
|
|
||||||
|
New registrant:
|
||||||
|
<%= render 'mailers/shared/registrant/registrant.en.text', registrant: new_registrant %>
|
||||||
|
|
||||||
|
Best Regards,
|
||||||
|
Estonian Internet Foundation
|
|
@ -760,8 +760,6 @@ en:
|
||||||
unimplemented_object_service: 'Unimplemented object service'
|
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'
|
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'
|
object_status_prohibits_operation: 'Object status prohibits operation'
|
||||||
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"
|
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"
|
pending_delete_expired_notification_subject: "Domeeni %{name} kustutamise taotlus on tühistatud / %{name} deletion cancelled"
|
||||||
delete_confirmation_subject: "Domeeni %{name} kustutatud / %{name} deleted"
|
delete_confirmation_subject: "Domeeni %{name} kustutatud / %{name} deleted"
|
||||||
|
|
|
@ -6,5 +6,9 @@ en:
|
||||||
subject: Domeeni %{domain_name} registreerija vahetus protseduur on algatatud / %{domain_name} registrant change
|
subject: Domeeni %{domain_name} registreerija vahetus protseduur on algatatud / %{domain_name} registrant change
|
||||||
rejected:
|
rejected:
|
||||||
subject: Domeeni %{domain_name} registreerija vahetuse taotlus tagasi lükatud / %{domain_name} registrant change declined
|
subject: Domeeni %{domain_name} registreerija vahetuse taotlus tagasi lükatud / %{domain_name} registrant change declined
|
||||||
|
confirmed:
|
||||||
|
subject: >-
|
||||||
|
Domeeni %{domain_name} registreerija vahetus teostatud
|
||||||
|
/ Registrant change of %{domain_name} has been finished
|
||||||
expired:
|
expired:
|
||||||
subject: Domeeni %{domain_name} registreerija vahetuse taotlus on tühistatud / %{domain_name} registrant change cancelled
|
subject: Domeeni %{domain_name} registreerija vahetuse taotlus on tühistatud / %{domain_name} registrant change cancelled
|
||||||
|
|
18
spec/jobs/domain_update_confirm_job_spec.rb
Normal file
18
spec/jobs/domain_update_confirm_job_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe DomainUpdateConfirmJob do
|
||||||
|
let(:domain) { instance_spy(Epp::Domain, registrant: registrant, errors: []) }
|
||||||
|
let(:registrant) { instance_double(Registrant) }
|
||||||
|
let(:registrant_change) { instance_spy(RegistrantChange) }
|
||||||
|
|
||||||
|
it 'confirms registrant change' do
|
||||||
|
expect(Epp::Domain).to receive(:find).and_return(domain)
|
||||||
|
expect(RegistrantChange).to receive(:new)
|
||||||
|
.with(domain: domain, old_registrant: registrant)
|
||||||
|
.and_return(registrant_change)
|
||||||
|
|
||||||
|
described_class.enqueue(domain_id = nil, action = RegistrantVerification::CONFIRMED)
|
||||||
|
|
||||||
|
expect(registrant_change).to have_received(:confirm)
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,59 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe DomainMailer do
|
|
||||||
describe '#registrant_updated_notification_for_new_registrant', db: true do
|
|
||||||
subject(:message) { described_class.registrant_updated_notification_for_new_registrant(55, 55, 55, true) }
|
|
||||||
|
|
||||||
context 'when contact address processing is enabled' do
|
|
||||||
before :example do
|
|
||||||
allow(Contact).to receive(:address_processing?).and_return(true)
|
|
||||||
create(:domain, id: 55)
|
|
||||||
create(:registrant_with_address, id: 55)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sends message' do
|
|
||||||
expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when contact address processing is disabled' do
|
|
||||||
before :example do
|
|
||||||
allow(Contact).to receive(:address_processing?).and_return(false)
|
|
||||||
create(:domain, id: 55)
|
|
||||||
create(:registrant_without_address, id: 55)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sends message' do
|
|
||||||
expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#registrant_updated_notification_for_old_registrant', db: true do
|
|
||||||
subject(:message) { described_class.registrant_updated_notification_for_old_registrant(55, 55, 55, true) }
|
|
||||||
|
|
||||||
context 'when contact address processing is enabled' do
|
|
||||||
before :example do
|
|
||||||
allow(Contact).to receive(:address_processing?).and_return(true)
|
|
||||||
create(:domain, id: 55)
|
|
||||||
create(:registrant_with_address, id: 55)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sends message' do
|
|
||||||
expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when contact address processing is disabled' do
|
|
||||||
before :example do
|
|
||||||
allow(Contact).to receive(:address_processing?).and_return(false)
|
|
||||||
create(:domain, id: 55)
|
|
||||||
create(:registrant_without_address, id: 55)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sends message' do
|
|
||||||
expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -94,6 +94,40 @@ RSpec.describe RegistrantChangeMailer do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#confirmed' do
|
||||||
|
let(:domain) { instance_spy(Domain, registrant_email: 'new.registrant@test.com') }
|
||||||
|
let(:old_registrant) { instance_spy(Registrant, email: 'old.registrant@test.com') }
|
||||||
|
let(:registrant_presenter) { instance_spy(RegistrantPresenter) }
|
||||||
|
let(:domain_presenter) { instance_spy(DomainPresenter) }
|
||||||
|
subject(:message) { described_class.confirmed(domain: domain, old_registrant: old_registrant) }
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
allow(RegistrantPresenter).to receive(:new).and_return(registrant_presenter)
|
||||||
|
allow(DomainPresenter).to receive(:new).and_return(domain_presenter)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has sender' do
|
||||||
|
expect(message.from).to eq(['noreply@internet.ee'])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has new registrant email as a recipient' do
|
||||||
|
expect(message.to).to include('new.registrant@test.com')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has old registrant email as a recipient' do
|
||||||
|
expect(message.to).to include('old.registrant@test.com')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has subject' do
|
||||||
|
allow(domain).to receive(:name).and_return('test.com')
|
||||||
|
expect(message.subject).to eq(t('registrant_change_mailer.confirmed.subject', domain_name: 'test.com'))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sends message' do
|
||||||
|
expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#rejected' do
|
describe '#rejected' do
|
||||||
let(:domain) { instance_spy(Domain, name: 'test.com', new_registrant_email: 'new.registrant@test.com') }
|
let(:domain) { instance_spy(Domain, name: 'test.com', new_registrant_email: 'new.registrant@test.com') }
|
||||||
let(:registrar) { instance_spy(Registrar) }
|
let(:registrar) { instance_spy(Registrar) }
|
||||||
|
|
20
spec/services/registrant_change_spec.rb
Normal file
20
spec/services/registrant_change_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe RegistrantChange do
|
||||||
|
describe '#confirm' do
|
||||||
|
let(:domain) { instance_double(Domain) }
|
||||||
|
let(:old_registrant) { instance_double(Registrant) }
|
||||||
|
let(:message) { instance_spy(ActionMailer::MessageDelivery) }
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
allow(RegistrantChangeMailer).to receive(:confirmed)
|
||||||
|
.with(domain: domain, old_registrant: old_registrant)
|
||||||
|
.and_return(message)
|
||||||
|
described_class.new(domain: domain, old_registrant: old_registrant).confirm
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'notifies registrant' do
|
||||||
|
expect(message).to have_received(:deliver_now)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue