diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb
index 4a47cc364..c1c6d0995 100644
--- a/app/jobs/domain_update_confirm_job.rb
+++ b/app/jobs/domain_update_confirm_job.rb
@@ -16,7 +16,9 @@ class DomainUpdateConfirmJob < Que::Job
domain.clean_pendings!
raise_errors!(domain)
when RegistrantVerification::REJECTED
- domain.send_mail :pending_update_rejected_notification_for_new_registrant
+ RegistrantChangeMailer.rejected(domain: domain, registrar: domain.registrar, registrant: domain.registrant)
+ .deliver
+
domain.poll_message!(:poll_pending_update_rejected_by_registrant)
domain.clean_pendings_lowlevel
end
diff --git a/app/mailers/.keep b/app/mailers/.keep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/app/mailers/registrant_change_mailer.rb b/app/mailers/registrant_change_mailer.rb
index a29f3aee1..c5efced86 100644
--- a/app/mailers/registrant_change_mailer.rb
+++ b/app/mailers/registrant_change_mailer.rb
@@ -1,36 +1,34 @@
class RegistrantChangeMailer < ApplicationMailer
include Que::Mailer
- def confirmation(domain:, registrant:)
+ def confirm(domain:, registrar:, current_registrant:, new_registrant:)
@domain = DomainPresenter.new(domain: domain, view: view_context)
- @registrar = RegistrarPresenter.new(registrar: domain.registrar, view: view_context)
- @registrant = RegistrantPresenter.new(registrant: registrant, view: view_context)
- @verification_url = confirm_url(domain)
+ @registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
+ @new_registrant = RegistrantPresenter.new(registrant: new_registrant, view: view_context)
+ @confirm_url = confirm_url(domain)
subject = default_i18n_subject(domain_name: domain.name)
- mail(to: registrant.email, subject: subject)
+ mail(to: current_registrant.email, subject: subject)
end
- def pending_update_notification_for_new_registrant(params)
- compose_from(params)
+ def notice(domain:, registrar:, current_registrant:, new_registrant:)
+ @domain = DomainPresenter.new(domain: domain, view: view_context)
+ @registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
+ @current_registrant = RegistrantPresenter.new(registrant: current_registrant, view: view_context)
+ @new_registrant = RegistrantPresenter.new(registrant: new_registrant, view: view_context)
+ @confirm_url = confirm_url(domain)
+
+ subject = default_i18n_subject(domain_name: domain.name)
+ mail(to: new_registrant.email, subject: subject)
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)
+ def rejected(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)
- @old_registrant = Registrant.find(old_registrant_id)
- @new_registrant = Registrant.find(new_registrant_id)
-
- 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_update_rejected_notification_for_new_registrant(params)
- compose_from(params)
+ subject = default_i18n_subject(domain_name: domain.name)
+ mail(to: domain.new_registrant_email, subject: subject)
end
def pending_update_expired_notification_for_new_registrant(params)
diff --git a/app/models/domain.rb b/app/models/domain.rb
index c97877047..33bfdfefc 100644
--- a/app/models/domain.rb
+++ b/app/models/domain.rb
@@ -380,12 +380,12 @@ class Domain < ActiveRecord::Base
new_registrant_name = registrant.name
current_registrant = Registrant.find(registrant_id_was)
- RegistrantChangeMailer.confirmation(domain: self, current_registrant: current_registrant).deliver
+ RegistrantChangeMailer.confirm(domain: self, registrar: registrar, current_registrant: current_registrant,
+ new_registrant: registrant).deliver
+ RegistrantChangeMailer.notice(domain: self, registrar: registrar, current_registrant: current_registrant,
+ new_registrant: registrant).deliver
- send_mail :pending_update_request_for_old_registrant
- send_mail :pending_update_notification_for_new_registrant
-
- reload # revert back to original
+ reload
self.pending_json = pending_json_cache
self.registrant_verification_token = token
@@ -397,8 +397,8 @@ class Domain < ActiveRecord::Base
pending_json['new_registrant_name'] = new_registrant_name
# This pending_update! method is triggered by before_update
- # Note, all before_save callbacks are excecuted before before_update,
- # thus automatic statuses has already excectued by this point
+ # Note, all before_save callbacks are executed before before_update,
+ # thus automatic statuses has already executed by this point
# and we need to trigger automatic statuses manually (second time).
manage_automatic_statuses
end
@@ -741,6 +741,10 @@ class Domain < ActiveRecord::Base
admin_contact_emails << registrant_email
end
+ def new_registrant_email
+ pending_json['new_registrant_email']
+ end
+
def self.to_csv
CSV.generate do |csv|
csv << column_names
diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb
index 49effbb1f..ef248774b 100644
--- a/app/models/domain_mail_model.rb
+++ b/app/models/domain_mail_model.rb
@@ -6,30 +6,6 @@ class DomainMailModel
@params = {errors: [], deliver_emails: domain.deliver_emails, id: domain.id}
end
- def pending_update_request_for_old_registrant
- registrant_old
- subject(:pending_update_request_for_old_registrant_subject)
- confirm_update
- domain_info
- compose
- end
-
- def pending_update_notification_for_new_registrant
- registrant # new registrant at this point
- subject(:pending_update_notification_for_new_registrant_subject)
- domain_info
- compose
- end
-
-
- def pending_update_rejected_notification_for_new_registrant
- registrant_pending
- subject(:pending_update_rejected_notification_for_new_registrant_subject)
- @params[:deliver_emails] = true # triggered from que
- @params[:registrar_name] = @domain.registrar.name
- compose
- end
-
def pending_update_expired_notification_for_new_registrant
registrant_pending
subject(:pending_update_expired_notification_for_new_registrant_subject)
diff --git a/app/views/mailers/domain_mailer/force_delete.html.erb b/app/views/mailers/domain_mailer/force_delete.html.erb
index 47f54f9b4..4b984bf57 100644
--- a/app/views/mailers/domain_mailer/force_delete.html.erb
+++ b/app/views/mailers/domain_mailer/force_delete.html.erb
@@ -21,7 +21,7 @@ Registrikood: <%= @registrant.ident %>
Lisaküsimuste korral võtke palun ühendust oma registripidajaga:
-<%= render 'mailers/domain_mailer/registrar/registrar.et.html', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
@@ -42,7 +42,7 @@ Registry code: <%= @registrant.ident %>
Should you have additional questions, please contact your registrar:
-<%= render 'mailers/domain_mailer/registrar/registrar.en.html', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
@@ -63,7 +63,7 @@ Registry code: <%= @registrant.ident %>
Просим обратиться к своему регистратору:
-<%= render 'mailers/domain_mailer/registrar/registrar.ru.html', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.ru.html', registrar: @registrar %>
diff --git a/app/views/mailers/domain_mailer/force_delete.text.erb b/app/views/mailers/domain_mailer/force_delete.text.erb
index 7ac6ceb26..688c5d445 100644
--- a/app/views/mailers/domain_mailer/force_delete.text.erb
+++ b/app/views/mailers/domain_mailer/force_delete.text.erb
@@ -15,7 +15,7 @@ Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.nam
Lisaküsimuste korral võtke palun ühendust oma registripidajaga:
-<%= render 'mailers/domain_mailer/registrar/registrar.et.text', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
@@ -36,7 +36,7 @@ If the transfer has not been made in 30 days, the domain <%= @domain.name %> wil
Should you have additional questions, please contact your registrar:
-<%= render 'mailers/domain_mailer/registrar/registrar.en.text', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
Уважаемое контактное лицо домена <%= @domain.name %>
@@ -56,7 +56,7 @@ EIS стало известно, что юридическое лицо с ре
Просим обратиться к своему регистратору:
-<%= render 'mailers/domain_mailer/registrar/registrar.ru.text', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.ru.text', registrar: @registrar %>
Lugupidamisega,
diff --git a/app/views/mailers/registrant_change_mailer/pending_update_request_for_old_registrant.html.erb b/app/views/mailers/registrant_change_mailer/confirm.html.erb
similarity index 71%
rename from app/views/mailers/registrant_change_mailer/pending_update_request_for_old_registrant.html.erb
rename to app/views/mailers/registrant_change_mailer/confirm.html.erb
index cba83c6e0..a2e889dc6 100644
--- a/app/views/mailers/registrant_change_mailer/pending_update_request_for_old_registrant.html.erb
+++ b/app/views/mailers/registrant_change_mailer/confirm.html.erb
@@ -2,17 +2,17 @@ Tere
Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
-<%= render 'mailers/domain_mailer/registrar/registrar.et.html', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
Uue registreerija andmed:
-<%= render 'mailers/domain_mailer/registrant/registrant.et.html', registrant: @new_registrant %>
+<%= render 'mailers/shared/registrant/registrant.et.html', registrant: @new_registrant %>
Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ei kinnita või tagasi lükka.
Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:
-<%= link_to @verification_url, @verification_url %>
+<%= link_to @confirm_url, @confirm_url %>
Lugupidamisega
Eesti Interneti Sihtasutus
@@ -23,16 +23,16 @@ Hi,
Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. In case of problems please turn to your registrar:
-<%= render 'mailers/domain_mailer/registrar/registrar.en.html', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
New registrant:
-<%= render 'mailers/domain_mailer/registrant/registrant.en.html', registrant: @new_registrant %>
+<%= render 'mailers/shared/registrant/registrant.en.html', registrant: @new_registrant %>
The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before.
To confirm the update please visit this website, once again review the data and press approve:
-<%= link_to @verification_url, @verification_url %>
+<%= link_to @confirm_url, @confirm_url %>
Best Regards,
Estonian Internet Foundation
diff --git a/app/views/mailers/registrant_change_mailer/pending_update_request_for_old_registrant.text.erb b/app/views/mailers/registrant_change_mailer/confirm.text.erb
similarity index 72%
rename from app/views/mailers/registrant_change_mailer/pending_update_request_for_old_registrant.text.erb
rename to app/views/mailers/registrant_change_mailer/confirm.text.erb
index f4ff079f2..2af2381fc 100644
--- a/app/views/mailers/registrant_change_mailer/pending_update_request_for_old_registrant.text.erb
+++ b/app/views/mailers/registrant_change_mailer/confirm.text.erb
@@ -2,14 +2,14 @@ Tere
Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
-<%= render 'mailers/domain_mailer/registrar/registrar.et.text', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
Uue registreerija andmed:
-<%= render 'mailers/domain_mailer/registrant/registrant.et.text', registrant: @new_registrant %>
+<%= render 'mailers/shared/registrant/registrant.et.text', registrant: @new_registrant %>
Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ei kinnita või tagasi lükka.
Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:
-<%= @verification_url %>
+<%= @confirm_url %>
Lugupidamisega
Eesti Interneti Sihtasutus
@@ -20,14 +20,14 @@ Hi,
Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. In case of problems please turn to your registrar:
-<%= render 'mailers/domain_mailer/registrar/registrar.en.text', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
New registrant:
-<%= render 'mailers/domain_mailer/registrant/registrant.en.text', registrant: @new_registrant %>
+<%= render 'mailers/shared/registrant/registrant.en.text', registrant: @new_registrant %>
The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before.
To confirm the update please visit this website, once again review the data and press approve:
-<%= @verification_url %>
+<%= @confirm_url %>
Best Regards,
Estonian Internet Foundation
diff --git a/app/views/mailers/registrant_change_mailer/pending_update_notification_for_new_registrant.html.erb b/app/views/mailers/registrant_change_mailer/notice.html.erb
similarity index 80%
rename from app/views/mailers/registrant_change_mailer/pending_update_notification_for_new_registrant.html.erb
rename to app/views/mailers/registrant_change_mailer/notice.html.erb
index 78f0458dc..6aecaf0b3 100644
--- a/app/views/mailers/registrant_change_mailer/pending_update_notification_for_new_registrant.html.erb
+++ b/app/views/mailers/registrant_change_mailer/notice.html.erb
@@ -4,11 +4,11 @@ Registripidaja <%= @registrar.name %> vahendusel on algatatud <%= @domain.name %
Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
-<%= render 'registrar.et.html', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
Uue registreerija andmed:
-<%= render 'registrant.et.html', registrant: @new_registrant %>
+<%= render 'mailers/shared/registrant/registrant.et.html', registrant: @new_registrant %>
Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiakse lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @current_registrant.name %> omanikuvahetuse tähtaegselt kinnitab.
@@ -25,11 +25,11 @@ Registrant change process for the domain <%= @domain.name %> has been started.
Please verify the details of the following change request. In case of problems contact your registrar:
-<%= render 'registrar.en.html', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
New registrant:
-<%= render 'registrant.en.html', registrant: @new_registrant %>
+<%= render 'mailers/shared/registrant/registrant.en.html', registrant: @new_registrant %>
The registrant change procedure will be completed only after the current registrant <%= @current_registrant.name %> has approved it.
diff --git a/app/views/mailers/registrant_change_mailer/pending_update_notification_for_new_registrant.text.erb b/app/views/mailers/registrant_change_mailer/notice.text.erb
similarity index 78%
rename from app/views/mailers/registrant_change_mailer/pending_update_notification_for_new_registrant.text.erb
rename to app/views/mailers/registrant_change_mailer/notice.text.erb
index ac781506e..bd1fb5d0f 100644
--- a/app/views/mailers/registrant_change_mailer/pending_update_notification_for_new_registrant.text.erb
+++ b/app/views/mailers/registrant_change_mailer/notice.text.erb
@@ -4,10 +4,10 @@ Registripidaja <%= @registrar.name %> vahendusel on algatatud <%= @domain.name %
Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
-<%= render 'registrar.et.text', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
Uue registreerija andmed:
-<%= render 'registrant.et.text', registrant: @new_registrant %>
+<%= render 'mailers/shared/registrant/registrant.et.text', registrant: @new_registrant %>
Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiakse lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @current_registrant.name %> omanikuvahetuse tähtaegselt kinnitab.
@@ -24,10 +24,10 @@ Registrant change process for the domain <%= @domain.name %> has been started.
Please verify the details of the following change request. In case of problems contact your registrar:
-<%= render 'registrar.en.text', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
New registrant:
-<%= render 'registrant.en.text', registrant: @new_registrant %>
+<%= render 'mailers/shared/registrant/registrant.en.text', registrant: @new_registrant %>
The registrant change procedure will be completed only after the current registrant <%= @current_registrant.name %> has approved it.
diff --git a/app/views/mailers/registrant_change_mailer/pending_update_rejected_notification_for_new_registrant.text.erb b/app/views/mailers/registrant_change_mailer/pending_update_rejected_notification_for_new_registrant.text.erb
deleted file mode 100644
index b54636f6e..000000000
--- a/app/views/mailers/registrant_change_mailer/pending_update_rejected_notification_for_new_registrant.text.erb
+++ /dev/null
@@ -1,23 +0,0 @@
-Tere
-
-Domeeni <%= @domain.name %> registreerija <%= @current_registrant.name %> on domeeni registreerija vahetamise taotluse tagasi lükanud.
-
-Küsimuste korral võtke palun ühendust oma registripidajaga:
-
-<%= render 'registrar.et.text', registrar: @registrar %>
-
-Lugupidamisega
-Eesti Interneti Sihtasutus
-
---------------------------------------
-
-Hi,
-
-Registrant change for the domain <%= @domain.name %> was rejected by the registrant <%= @current_registrant.name %>.
-
-Please contact your registrar if you have any questions:
-
-<%= render 'registrar.en.text', registrar: @registrar %>
-
-Best Regards,
-Estonian Internet Foundation
diff --git a/app/views/mailers/registrant_change_mailer/pending_update_rejected_notification_for_new_registrant.html.erb b/app/views/mailers/registrant_change_mailer/rejected.html.erb
similarity index 52%
rename from app/views/mailers/registrant_change_mailer/pending_update_rejected_notification_for_new_registrant.html.erb
rename to app/views/mailers/registrant_change_mailer/rejected.html.erb
index 97413078a..2521dd52a 100644
--- a/app/views/mailers/registrant_change_mailer/pending_update_rejected_notification_for_new_registrant.html.erb
+++ b/app/views/mailers/registrant_change_mailer/rejected.html.erb
@@ -1,10 +1,10 @@
Tere
-Domeeni <%= @domain.name %> registreerija <%= @current_registrant.name %> on domeeni registreerija vahetamise taotluse tagasi lükanud.
+Domeeni <%= @domain.name %> registreerija <%= @registrant.name %> on domeeni registreerija vahetamise taotluse tagasi lükanud.
Küsimuste korral võtke palun ühendust oma registripidajaga:
-<%= render 'registrar.et.html', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
Lugupidamisega
@@ -14,11 +14,11 @@ Eesti Interneti Sihtasutus
Hi,
-Registrant change for the domain <%= @domain.name %> was rejected by the registrant <%= @current_registrant.name %>.
+Registrant change for the domain <%= @domain.name %> was rejected by the registrant <%= @registrant.name %>.
Please contact your registrar if you have any questions:
-<%= render 'registrar.en.html', registrar: @registrar %>
+<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
Best Regards,
diff --git a/app/views/mailers/registrant_change_mailer/rejected.text.erb b/app/views/mailers/registrant_change_mailer/rejected.text.erb
new file mode 100644
index 000000000..166f6f394
--- /dev/null
+++ b/app/views/mailers/registrant_change_mailer/rejected.text.erb
@@ -0,0 +1,23 @@
+Tere
+
+Domeeni <%= @domain.name %> registreerija <%= @registrant.name %> on domeeni registreerija vahetamise taotluse tagasi lükanud.
+
+Küsimuste korral võtke palun ühendust oma registripidajaga:
+
+<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
+
+Lugupidamisega
+Eesti Interneti Sihtasutus
+
+--------------------------------------
+
+Hi,
+
+Registrant change for the domain <%= @domain.name %> was rejected by the registrant <%= @registrant.name %>.
+
+Please contact your registrar if you have any questions:
+
+<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
+
+Best Regards,
+Estonian Internet Foundation
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 725dfffc3..be9539d6a 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -796,8 +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_notification_for_new_registrant_subject: "Domeeni %{name} registreerija vahetus protseduur on algatatud / %{name} registrant change"
- pending_update_rejected_notification_for_new_registrant_subject: "Domeeni %{name} registreerija vahetuse taotlus tagasi lükatud / %{name} registrant change declined"
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.'
diff --git a/config/locales/mailers/registrant_change.en.yml b/config/locales/mailers/registrant_change.en.yml
index e7a5437b0..83fba025b 100644
--- a/config/locales/mailers/registrant_change.en.yml
+++ b/config/locales/mailers/registrant_change.en.yml
@@ -1,4 +1,8 @@
en:
registrant_change_mailer:
- confirmation:
+ confirm:
subject: Kinnitustaotlus domeeni %{domain_name} registreerija vahetuseks / Application for approval for registrant change of %{domain_name}
+ notice:
+ 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
diff --git a/spec/mailers/registrant_change_mailer_spec.rb b/spec/mailers/registrant_change_mailer_spec.rb
index a26b507d3..d532d1e24 100644
--- a/spec/mailers/registrant_change_mailer_spec.rb
+++ b/spec/mailers/registrant_change_mailer_spec.rb
@@ -1,27 +1,33 @@
require 'rails_helper'
RSpec.describe RegistrantChangeMailer do
- describe '#confirmation' do
+ describe '#confirm' do
let(:domain) { instance_spy(Domain, name: 'test.com') }
- let(:registrant) { instance_spy(Registrant, email: 'registrant@test.com') }
+ let(:registrar) { instance_spy(Registrar) }
+ let(:current_registrant) { instance_spy(Registrant, email: 'registrant@test.com') }
+ let(:new_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.confirmation(domain: domain,
- registrant: registrant,
- ) }
+ let(:new_registrant_presenter) { instance_spy(RegistrantPresenter) }
+
+ subject(:message) { described_class.confirm(domain: domain,
+ registrar: registrar,
+ current_registrant: current_registrant,
+ new_registrant: new_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)
+ expect(RegistrantPresenter).to receive(:new).and_return(new_registrant_presenter)
end
it 'has sender' do
expect(message.from).to eq(['noreply@internet.ee'])
end
- it 'has registrant email as a recipient' do
+ it 'has current registrant\s email as a recipient' do
expect(message.to).to match_array(['registrant@test.com'])
end
@@ -43,4 +49,88 @@ RSpec.describe RegistrantChangeMailer do
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
end
+
+ describe '#notice' do
+ let(:domain) { instance_spy(Domain, name: 'test.com') }
+ let(:registrar) { instance_spy(Registrar) }
+ let(:current_registrant) { instance_spy(Registrant) }
+ let(:new_registrant) { instance_spy(Registrant, email: 'registrant@test.com') }
+
+ let(:domain_presenter) { instance_spy(DomainPresenter) }
+ let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
+ let(:current_registrant_presenter) { instance_spy(RegistrantPresenter) }
+ let(:new_registrant_presenter) { instance_spy(RegistrantPresenter) }
+
+ subject(:message) { described_class.notice(domain: domain,
+ registrar: registrar,
+ current_registrant: current_registrant,
+ new_registrant: new_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).with(registrant: current_registrant, view: anything).and_return(current_registrant_presenter)
+ expect(RegistrantPresenter).to receive(:new).with(registrant: new_registrant, view: anything).and_return(new_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(['registrant@test.com'])
+ end
+
+ it 'has subject' do
+ subject = 'Domeeni test.com registreerija vahetus protseduur on algatatud' \
+ ' / test.com registrant change'
+
+ expect(message.subject).to eq(subject)
+ end
+
+ it 'sends message' do
+ expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
+ end
+ end
+
+ describe '#rejected' 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.rejected(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 tagasi lükatud' \
+ ' / test.com registrant change declined'
+
+ 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
diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb
index 1a3e47bc6..fe660c7ec 100644
--- a/spec/models/domain_spec.rb
+++ b/spec/models/domain_spec.rb
@@ -891,4 +891,52 @@ RSpec.describe Domain, db: false do
expect(described_class.delete_candidates.ids).to eq([1])
end
end
+
+ describe '#pending_update!', db: false do
+ let(:domain) { described_class.new }
+ let(:current_registrant) { FactoryGirl.build_stubbed(:registrant) }
+ let(:new_registrant) { FactoryGirl.build_stubbed(:registrant) }
+ let(:message) { instance_double(Mail::Message) }
+
+ before :example do
+ expect(Registrant).to receive(:find).and_return(current_registrant)
+ expect(domain).to receive_messages(
+ reload: true,
+ pending_update?: false,
+ registrant_verification_asked?: true,
+ registrar: 'registrar',
+ registrant: new_registrant,
+ manage_automatic_statuses: true
+ )
+ end
+
+ it 'sends confirm and notice emails' do
+ allow(RegistrantChangeMailer).to receive(:notice).and_return(message)
+ expect(RegistrantChangeMailer).to receive(:confirm)
+ .with(
+ domain: domain,
+ registrar: 'registrar',
+ current_registrant: current_registrant,
+ new_registrant: new_registrant)
+ .and_return(message)
+
+ expect(RegistrantChangeMailer).to receive(:notice)
+ .with(
+ domain: domain,
+ registrar: 'registrar',
+ current_registrant: current_registrant,
+ new_registrant: new_registrant)
+ .and_return(message)
+ expect(message).to receive(:deliver).exactly(2).times
+ domain.pending_update!
+ end
+ end
+
+ describe '#new_registrant_email' do
+ let(:domain) { described_class.new(pending_json: { new_registrant_email: 'test@test.com' }) }
+
+ it 'returns new registrant\'s email' do
+ expect(domain.new_registrant_email).to eq('test@test.com')
+ end
+ end
end
diff --git a/spec/views/mailers/domain_mailer/force_delete.html.erb_spec.rb b/spec/views/mailers/domain_mailer/force_delete.html.erb_spec.rb
index d201a6540..462211b78 100644
--- a/spec/views/mailers/domain_mailer/force_delete.html.erb_spec.rb
+++ b/spec/views/mailers/domain_mailer/force_delete.html.erb_spec.rb
@@ -3,9 +3,9 @@ require_relative 'force_delete_shared'
RSpec.describe 'mailers/domain_mailer/force_delete.html.erb' do
before :example do
- stub_template 'mailers/domain_mailer/registrar/_registrar.et.html' => 'test registrar estonian'
- stub_template 'mailers/domain_mailer/registrar/_registrar.en.html' => 'test registrar english'
- stub_template 'mailers/domain_mailer/registrar/_registrar.ru.html' => 'test registrar russian'
+ stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian'
+ stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english'
+ stub_template 'mailers/shared/registrar/_registrar.ru.html' => 'test registrar russian'
end
include_examples 'domain mailer force delete'
diff --git a/spec/views/mailers/domain_mailer/force_delete.text.erb_spec.rb b/spec/views/mailers/domain_mailer/force_delete.text.erb_spec.rb
index 824746208..6aaf08820 100644
--- a/spec/views/mailers/domain_mailer/force_delete.text.erb_spec.rb
+++ b/spec/views/mailers/domain_mailer/force_delete.text.erb_spec.rb
@@ -3,9 +3,9 @@ require_relative 'force_delete_shared'
RSpec.describe 'mailers/domain_mailer/force_delete.text.erb' do
before :example do
- stub_template 'mailers/domain_mailer/registrar/_registrar.et.text' => 'test registrar estonian'
- stub_template 'mailers/domain_mailer/registrar/_registrar.en.text' => 'test registrar english'
- stub_template 'mailers/domain_mailer/registrar/_registrar.ru.text' => 'test registrar russian'
+ stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian'
+ stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english'
+ stub_template 'mailers/shared/registrar/_registrar.ru.text' => 'test registrar russian'
end
include_examples 'domain mailer force delete'
diff --git a/spec/views/mailers/registrant_change_mailer/confirmation.html.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/confirm.html.erb_spec.rb
similarity index 69%
rename from spec/views/mailers/registrant_change_mailer/confirmation.html.erb_spec.rb
rename to spec/views/mailers/registrant_change_mailer/confirm.html.erb_spec.rb
index c59dd4e55..e8aa20326 100644
--- a/spec/views/mailers/registrant_change_mailer/confirmation.html.erb_spec.rb
+++ b/spec/views/mailers/registrant_change_mailer/confirm.html.erb_spec.rb
@@ -1,7 +1,7 @@
require 'rails_helper'
-require_relative 'confirmation_shared'
+require_relative 'confirm_shared'
-RSpec.describe 'mailers/registrant_change_mailer/confirmation.html.erb' do
+RSpec.describe 'mailers/registrant_change_mailer/confirm.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'
@@ -9,5 +9,5 @@ RSpec.describe 'mailers/registrant_change_mailer/confirmation.html.erb' do
stub_template 'mailers/shared/registrant/_registrant.en.html' => 'test new registrant english'
end
- include_examples 'domain mailer pending update request for old registrant'
+ include_examples 'registrant change mailer confirm'
end
diff --git a/spec/views/mailers/registrant_change_mailer/confirmation.text.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/confirm.text.erb_spec.rb
similarity index 69%
rename from spec/views/mailers/registrant_change_mailer/confirmation.text.erb_spec.rb
rename to spec/views/mailers/registrant_change_mailer/confirm.text.erb_spec.rb
index 37edf78e9..f98f4ec32 100644
--- a/spec/views/mailers/registrant_change_mailer/confirmation.text.erb_spec.rb
+++ b/spec/views/mailers/registrant_change_mailer/confirm.text.erb_spec.rb
@@ -1,7 +1,7 @@
require 'rails_helper'
-require_relative 'confirmation_shared'
+require_relative 'confirm_shared'
-RSpec.describe 'mailers/registrant_change_mailer/confirmation.text.erb' do
+RSpec.describe 'mailers/registrant_change_mailer/confirm.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'
@@ -9,5 +9,5 @@ RSpec.describe 'mailers/registrant_change_mailer/confirmation.text.erb' do
stub_template 'mailers/shared/registrant/_registrant.en.text' => 'test new registrant english'
end
- include_examples 'domain mailer pending update request for old registrant'
+ include_examples 'registrant change mailer confirm'
end
diff --git a/spec/views/mailers/registrant_change_mailer/confirmation_shared.rb b/spec/views/mailers/registrant_change_mailer/confirm_shared.rb
similarity index 81%
rename from spec/views/mailers/registrant_change_mailer/confirmation_shared.rb
rename to spec/views/mailers/registrant_change_mailer/confirm_shared.rb
index ed760aeed..8949b5070 100644
--- a/spec/views/mailers/registrant_change_mailer/confirmation_shared.rb
+++ b/spec/views/mailers/registrant_change_mailer/confirm_shared.rb
@@ -1,6 +1,6 @@
require 'rails_helper'
-RSpec.shared_examples 'domain mailer pending update request for old registrant' do
+RSpec.shared_examples 'registrant change mailer confirm' do
let(:domain) { instance_spy(DomainPresenter) }
let(:lang_count) { 2 }
@@ -8,7 +8,7 @@ RSpec.shared_examples 'domain mailer pending update request for old registrant'
assign(:domain, domain)
assign(:registrar, nil)
assign(:new_registrant, nil)
- assign(:verification_url, 'test verification url')
+ assign(:confirm_url, 'test confirm url')
end
it 'has registrar info in estonian' do
@@ -31,10 +31,10 @@ RSpec.shared_examples 'domain mailer pending update request for old registrant'
expect(rendered).to have_text('test new registrant english')
end
- it 'has verification url' do
+ it 'has confirm url' do
mention_count = 1 * lang_count
render
- expect(rendered).to have_text('test verification url', count: mention_count)
+ expect(rendered).to have_text('test confirm url', count: mention_count)
end
domain_attributes = %i(
diff --git a/spec/views/mailers/registrant_change_mailer/notice.html.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/notice.html.erb_spec.rb
new file mode 100644
index 000000000..c5d4f2974
--- /dev/null
+++ b/spec/views/mailers/registrant_change_mailer/notice.html.erb_spec.rb
@@ -0,0 +1,13 @@
+require 'rails_helper'
+require_relative 'notice_shared'
+
+RSpec.describe 'mailers/registrant_change_mailer/notice.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'
+ stub_template 'mailers/shared/registrant/_registrant.et.html' => 'test new registrant estonian'
+ stub_template 'mailers/shared/registrant/_registrant.en.html' => 'test new registrant english'
+ end
+
+ include_examples 'registrant change mailer notice'
+end
diff --git a/spec/views/mailers/registrant_change_mailer/notice.text.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/notice.text.erb_spec.rb
new file mode 100644
index 000000000..ab685b12f
--- /dev/null
+++ b/spec/views/mailers/registrant_change_mailer/notice.text.erb_spec.rb
@@ -0,0 +1,13 @@
+require 'rails_helper'
+require_relative 'notice_shared'
+
+RSpec.describe 'mailers/registrant_change_mailer/notice.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'
+ stub_template 'mailers/shared/registrant/_registrant.et.text' => 'test new registrant estonian'
+ stub_template 'mailers/shared/registrant/_registrant.en.text' => 'test new registrant english'
+ end
+
+ include_examples 'registrant change mailer notice'
+end
diff --git a/spec/views/mailers/registrant_change_mailer/pending_update_notification_for_new_registrant_shared.rb b/spec/views/mailers/registrant_change_mailer/notice_shared.rb
similarity index 65%
rename from spec/views/mailers/registrant_change_mailer/pending_update_notification_for_new_registrant_shared.rb
rename to spec/views/mailers/registrant_change_mailer/notice_shared.rb
index 9b95af51b..40d42cd1c 100644
--- a/spec/views/mailers/registrant_change_mailer/pending_update_notification_for_new_registrant_shared.rb
+++ b/spec/views/mailers/registrant_change_mailer/notice_shared.rb
@@ -1,13 +1,16 @@
require 'rails_helper'
-RSpec.shared_examples 'domain mailer pending update notification for new registrant' do
+RSpec.shared_examples 'registrant change mailer notice' 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(:current_registrant, registrant)
+ assign(:new_registrant, registrant)
end
it 'has registrar info in estonian' do
@@ -20,10 +23,14 @@ RSpec.shared_examples 'domain mailer pending update notification for new registr
expect(rendered).to have_text('test registrar english')
end
- it 'has registrar name' do
- expect(registrar).to receive(:name).and_return('test registrar name')
+ it 'has new registrant info in estonian' do
render
- expect(rendered).to have_text('test registrar name')
+ expect(rendered).to have_text('test new registrant estonian')
+ end
+
+ it 'has new registrant info in english' do
+ render
+ expect(rendered).to have_text('test new registrant english')
end
domain_attributes = %i(
diff --git a/spec/views/mailers/registrant_change_mailer/pending_update_notification_for_new_registrant.html.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/pending_update_notification_for_new_registrant.html.erb_spec.rb
deleted file mode 100644
index 9b6519654..000000000
--- a/spec/views/mailers/registrant_change_mailer/pending_update_notification_for_new_registrant.html.erb_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require 'rails_helper'
-require_relative 'pending_update_notification_for_new_registrant_shared'
-
-RSpec.describe 'mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb' do
- include_examples 'domain mailer pending update notification for new registrant'
-end
diff --git a/spec/views/mailers/registrant_change_mailer/pending_update_notification_for_new_registrant.text.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/pending_update_notification_for_new_registrant.text.erb_spec.rb
deleted file mode 100644
index cf39231b4..000000000
--- a/spec/views/mailers/registrant_change_mailer/pending_update_notification_for_new_registrant.text.erb_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require 'rails_helper'
-require_relative 'pending_update_notification_for_new_registrant_shared'
-
-RSpec.describe 'mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb' do
- include_examples 'domain mailer pending update notification for new registrant'
-
-
-
-end
diff --git a/spec/views/mailers/registrant_change_mailer/rejected.html.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/rejected.html.erb_spec.rb
new file mode 100644
index 000000000..be37545c6
--- /dev/null
+++ b/spec/views/mailers/registrant_change_mailer/rejected.html.erb_spec.rb
@@ -0,0 +1,11 @@
+require 'rails_helper'
+require_relative 'rejected_shared'
+
+RSpec.describe 'mailers/registrant_change_mailer/rejected.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 rejected'
+end
diff --git a/spec/views/mailers/registrant_change_mailer/rejected.text.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/rejected.text.erb_spec.rb
new file mode 100644
index 000000000..af9d78a69
--- /dev/null
+++ b/spec/views/mailers/registrant_change_mailer/rejected.text.erb_spec.rb
@@ -0,0 +1,11 @@
+require 'rails_helper'
+require_relative 'rejected_shared'
+
+RSpec.describe 'mailers/registrant_change_mailer/rejected.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 rejected'
+end
diff --git a/spec/views/mailers/registrant_change_mailer/rejected_shared.rb b/spec/views/mailers/registrant_change_mailer/rejected_shared.rb
new file mode 100644
index 000000000..f6e21d57a
--- /dev/null
+++ b/spec/views/mailers/registrant_change_mailer/rejected_shared.rb
@@ -0,0 +1,48 @@
+require 'rails_helper'
+
+RSpec.shared_examples 'registrant change mailer rejected' 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
+ expect(domain).to receive(attr_name).exactly(lang_count).times.and_return("test domain #{attr_name}")
+ render
+ expect(rendered).to have_text("test domain #{attr_name}", count: lang_count)
+ end
+ end
+
+ registrant_attributes = %i(
+ name
+ )
+
+ registrant_attributes.each do |attr_name|
+ it "has registrant #{attr_name}" do
+ expect(registrant).to receive(attr_name).exactly(lang_count).times.and_return("test registrant #{attr_name}")
+ render
+ expect(rendered).to have_text("test registrant #{attr_name}", count: lang_count)
+ end
+ end
+end