diff --git a/app/jobs/domain_delete_confirm_email_job.rb b/app/jobs/domain_delete_confirm_email_job.rb
new file mode 100644
index 000000000..d3f06c189
--- /dev/null
+++ b/app/jobs/domain_delete_confirm_email_job.rb
@@ -0,0 +1,9 @@
+class DomainDeleteConfirmEmailJob < Que::Job
+ def run(domain_id)
+ domain = Domain.find(domain_id)
+
+ DomainDeleteMailer.confirm(domain: domain,
+ registrar: domain.registrar,
+ registrant: domain.registrant).deliver_now
+ end
+end
diff --git a/app/jobs/domain_delete_forced_email_job.rb b/app/jobs/domain_delete_forced_email_job.rb
new file mode 100644
index 000000000..d28836b90
--- /dev/null
+++ b/app/jobs/domain_delete_forced_email_job.rb
@@ -0,0 +1,9 @@
+class DomainDeleteForcedEmailJob < Que::Job
+ def run(domain_id)
+ domain = Domain.find(domain_id)
+
+ DomainDeleteMailer.forced(domain: domain,
+ registrar: domain.registrar,
+ registrant: domain.registrant).deliver_now
+ end
+end
diff --git a/app/jobs/domain_expiration_email_job.rb b/app/jobs/domain_expire_email_job.rb
similarity index 77%
rename from app/jobs/domain_expiration_email_job.rb
rename to app/jobs/domain_expire_email_job.rb
index 9d7a5f931..9b70a54e6 100644
--- a/app/jobs/domain_expiration_email_job.rb
+++ b/app/jobs/domain_expire_email_job.rb
@@ -1,10 +1,9 @@
-class DomainExpirationEmailJob < Que::Job
+class DomainExpireEmailJob < Que::Job
def run(domain_id)
domain = Domain.find(domain_id)
return if domain.registered?
DomainExpireMailer.expired(domain: domain, registrar: domain.registrar).deliver_now
- destroy
end
end
diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb
index 459bfc533..7d4fc488f 100644
--- a/app/jobs/domain_update_confirm_job.rb
+++ b/app/jobs/domain_update_confirm_job.rb
@@ -16,8 +16,9 @@ class DomainUpdateConfirmJob < Que::Job
domain.clean_pendings!
raise_errors!(domain)
when RegistrantVerification::REJECTED
- RegistrantChangeMailer.rejected(domain: domain, registrar: domain.registrar, registrant: domain.registrant)
- .deliver_now
+ RegistrantChangeMailer.rejected(domain: domain,
+ registrar: domain.registrar,
+ registrant: domain.registrant).deliver_now
domain.poll_message!(:poll_pending_update_rejected_by_registrant)
domain.clean_pendings_lowlevel
diff --git a/app/jobs/registrant_change_confirm_email_job.rb b/app/jobs/registrant_change_confirm_email_job.rb
new file mode 100644
index 000000000..5f93a066b
--- /dev/null
+++ b/app/jobs/registrant_change_confirm_email_job.rb
@@ -0,0 +1,11 @@
+class RegistrantChangeConfirmEmailJob < Que::Job
+ def run(domain_id, new_registrant_id)
+ domain = Domain.find(domain_id)
+ new_registrant = Registrant.find(new_registrant_id)
+
+ RegistrantChangeMailer.confirm(domain: domain,
+ registrar: domain.registrar,
+ current_registrant: domain.registrant,
+ new_registrant: new_registrant).deliver_now
+ end
+end
diff --git a/app/jobs/registrant_change_expired_email_job.rb b/app/jobs/registrant_change_expired_email_job.rb
new file mode 100644
index 000000000..73a90d8fe
--- /dev/null
+++ b/app/jobs/registrant_change_expired_email_job.rb
@@ -0,0 +1,8 @@
+class RegistrantChangeExpiredEmailJob < Que::Job
+ def run(domain_id)
+ domain = Domain.find(domain_id)
+ RegistrantChangeMailer.expired(domain: domain,
+ registrar: domain.registrar,
+ registrant: domain.registrant).deliver_now
+ end
+end
diff --git a/app/jobs/registrant_change_notice_email_job.rb b/app/jobs/registrant_change_notice_email_job.rb
new file mode 100644
index 000000000..b9f3f992c
--- /dev/null
+++ b/app/jobs/registrant_change_notice_email_job.rb
@@ -0,0 +1,11 @@
+class RegistrantChangeNoticeEmailJob < Que::Job
+ def run(domain_id, new_registrant_id)
+ domain = Domain.find(domain_id)
+ new_registrant = Registrant.find(new_registrant_id)
+
+ RegistrantChangeMailer.notice(domain: domain,
+ registrar: domain.registrar,
+ current_registrant: domain.registrant,
+ new_registrant: new_registrant).deliver_now
+ end
+end
diff --git a/app/mailers/delete_domain_mailer.rb b/app/mailers/delete_domain_mailer.rb
deleted file mode 100644
index 4a8f4f7c4..000000000
--- a/app/mailers/delete_domain_mailer.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-class DeleteDomainMailer < ApplicationMailer
- include Que::Mailer
-
- def pending(domain:, old_registrant:)
- @domain = DomainPresenter.new(domain: domain, view: view_context)
- @registrar = RegistrarPresenter.new(registrar: domain.registrar, view: view_context)
- @verification_url = verification_url(domain)
-
- subject = default_i18n_subject(domain_name: domain.name)
- mail(to: old_registrant.email, subject: subject)
- end
-
- private
-
- def verification_url(domain)
- registrant_domain_delete_confirm_url(domain, token: domain.registrant_verification_token)
- end
-end
diff --git a/app/mailers/domain_delete_mailer.rb b/app/mailers/domain_delete_mailer.rb
new file mode 100644
index 000000000..c8703e0ac
--- /dev/null
+++ b/app/mailers/domain_delete_mailer.rb
@@ -0,0 +1,24 @@
+class DomainDeleteMailer < ApplicationMailer
+ def confirm(domain:, registrar:, registrant:)
+ @domain = DomainPresenter.new(domain: domain, view: view_context)
+ @registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
+ @confirm_url = confirm_url(domain)
+
+ subject = default_i18n_subject(domain_name: domain.name)
+ mail(to: registrant.email, subject: subject)
+ end
+
+ def forced(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)
+
+ mail(to: domain.primary_contact_emails)
+ end
+
+ private
+
+ def confirm_url(domain)
+ registrant_domain_delete_confirm_url(domain, token: domain.registrant_verification_token)
+ end
+end
diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb
index de995173a..bb8c55492 100644
--- a/app/mailers/domain_mailer.rb
+++ b/app/mailers/domain_mailer.rb
@@ -75,14 +75,6 @@ class DomainMailer < ApplicationMailer
name: @domain.name)} [#{@domain.name}]")
end
- def force_delete(domain:)
- @domain = DomainPresenter.new(domain: domain, view: view_context)
- @registrar = RegistrarPresenter.new(registrar: domain.registrar, view: view_context)
- @registrant = RegistrantPresenter.new(registrant: domain.registrant, view: view_context)
-
- mail(to: domain.primary_contact_emails)
- end
-
private
# app/models/DomainMailModel provides the data for mail that can be composed_from
# which ensures that values of objects are captured when they are valid, not later when this method is executed
diff --git a/app/models/domain.rb b/app/models/domain.rb
index 33bfdfefc..dff0ecddc 100644
--- a/app/models/domain.rb
+++ b/app/models/domain.rb
@@ -379,11 +379,8 @@ class Domain < ActiveRecord::Base
new_registrant_email = registrant.email
new_registrant_name = registrant.name
- current_registrant = Registrant.find(registrant_id_was)
- 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
+ RegistrantChangeConfirmEmailJob.enqueue(id, new_registrant_id)
+ RegistrantChangeNoticeEmailJob.enqueue(id, new_registrant_id)
reload
@@ -444,8 +441,7 @@ class Domain < ActiveRecord::Base
pending_delete_confirmation!
save(validate: false) # should check if this did succeed
- old_registrant = Registrant.find(registrant_id_was)
- DeleteDomainMailer.pending(domain: self, old_registrant: old_registrant).deliver
+ DomainDeleteConfirmEmailJob.enqueue(id)
end
def cancel_pending_delete
@@ -566,12 +562,15 @@ class Domain < ActiveRecord::Base
end
self.force_delete_at = (Time.zone.now + (Setting.redemption_grace_period.days + 1.day)).utc.beginning_of_day unless force_delete_at
+
transaction do
save!(validate: false)
registrar.messages.create!(
body: I18n.t('force_delete_set_on_domain', domain: name)
)
- DomainMailer.force_delete(domain: self).deliver
+
+ DomainDeleteForcedEmailJob.enqueue(id)
+
return true
end
false
@@ -745,6 +744,10 @@ class Domain < ActiveRecord::Base
pending_json['new_registrant_email']
end
+ def new_registrant_id
+ pending_json['new_registrant_id']
+ end
+
def self.to_csv
CSV.generate do |csv|
csv << column_names
diff --git a/app/models/domain_cron.rb b/app/models/domain_cron.rb
index 2e23a08d5..c3a698fbc 100644
--- a/app/models/domain_cron.rb
+++ b/app/models/domain_cron.rb
@@ -16,8 +16,7 @@ class DomainCron
end
count += 1
if domain.pending_update?
- RegistrantChangeMailer.expired(domain: domain, registrar: domain.registrar, registrant: domain.registrant)
- .deliver
+ RegistrantChangeExpiredEmailJob.enqueue(domain.id)
end
if domain.pending_delete? || domain.pending_delete_confirmation?
DomainMailer.pending_delete_expired_notification(domain.id, true).deliver
@@ -49,7 +48,7 @@ class DomainCron
saved = domain.save(validate: false)
if saved
- DomainExpirationEmailJob.enqueue(domain.id, run_at: send_time)
+ DomainExpireEmailJob.enqueue(domain.id, run_at: send_time)
marked += 1
end
end
diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb
index 2feef25be..55590e70f 100644
--- a/app/models/epp/domain.rb
+++ b/app/models/epp/domain.rb
@@ -571,7 +571,6 @@ class Epp::Domain < Domain
frame.css('delete').children.css('delete').attr('verified').to_s.downcase != 'yes'
registrant_verification_asked!(frame.to_s, user_id)
- self.deliver_emails = true # turn on email delivery for epp
pending_delete!
manage_automatic_statuses
true # aka 1001 pending_delete
diff --git a/app/views/mailers/delete_domain_mailer/pending.html.erb b/app/views/mailers/domain_delete_mailer/confirm.html.erb
similarity index 92%
rename from app/views/mailers/delete_domain_mailer/pending.html.erb
rename to app/views/mailers/domain_delete_mailer/confirm.html.erb
index ced759234..e62890ed1 100644
--- a/app/views/mailers/delete_domain_mailer/pending.html.erb
+++ b/app/views/mailers/domain_delete_mailer/confirm.html.erb
@@ -8,7 +8,7 @@ Registrisse laekus taotlus domeeni <%= @domain.name %> kustutamiseks. Palun veen
Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan.
Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ise ei kinnita või tagasi lükka.
-<%= link_to @verification_url, @verification_url %>
+<%= link_to @confirm_url, @confirm_url %>
Lugupidamisega
Eesti Interneti Sihtasutus
@@ -23,7 +23,7 @@ Application for deletion of your domain <%= @domain.name %> has been filed. Plea
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 %>
The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automatically rejected if it is not approved nor rejected before.
diff --git a/app/views/mailers/delete_domain_mailer/pending.text.erb b/app/views/mailers/domain_delete_mailer/confirm.text.erb
similarity index 96%
rename from app/views/mailers/delete_domain_mailer/pending.text.erb
rename to app/views/mailers/domain_delete_mailer/confirm.text.erb
index a16fd82ff..7d2e1cb05 100644
--- a/app/views/mailers/delete_domain_mailer/pending.text.erb
+++ b/app/views/mailers/domain_delete_mailer/confirm.text.erb
@@ -7,7 +7,7 @@ Registrisse laekus taotlus domeeni <%= @domain.name %> kustutamiseks. Palun veen
Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan.
Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ise ei kinnita või tagasi lükka.
-<%= @verification_url %>
+<%= @confirm_url %>
Lugupidamisega
Eesti Interneti Sihtasutus
@@ -21,7 +21,7 @@ Application for deletion of your domain <%= @domain.name %> has been filed. Plea
<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
To confirm the update please visit this website, once again review the data and press approve:
-<%= @verification_url %>
+<%= @confirm_url %>
The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automatically rejected if it is not approved nor rejected before.
diff --git a/app/views/mailers/domain_mailer/force_delete.html.erb b/app/views/mailers/domain_delete_mailer/forced.html.erb
similarity index 100%
rename from app/views/mailers/domain_mailer/force_delete.html.erb
rename to app/views/mailers/domain_delete_mailer/forced.html.erb
diff --git a/app/views/mailers/domain_mailer/force_delete.text.erb b/app/views/mailers/domain_delete_mailer/forced.text.erb
similarity index 100%
rename from app/views/mailers/domain_mailer/force_delete.text.erb
rename to app/views/mailers/domain_delete_mailer/forced.text.erb
diff --git a/config/locales/mailers/domain.en.yml b/config/locales/mailers/domain.en.yml
deleted file mode 100644
index fadb5a7f6..000000000
--- a/config/locales/mailers/domain.en.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-en:
- domain_mailer:
- force_delete:
- subject: Kustutusmenetluse teade
diff --git a/config/locales/mailers/delete_domain.en.yml b/config/locales/mailers/domain_delete.en.yml
similarity index 62%
rename from config/locales/mailers/delete_domain.en.yml
rename to config/locales/mailers/domain_delete.en.yml
index 43cfff784..93e656b1e 100644
--- a/config/locales/mailers/delete_domain.en.yml
+++ b/config/locales/mailers/domain_delete.en.yml
@@ -1,4 +1,6 @@
en:
- delete_domain_mailer:
- pending:
+ domain_delete_mailer:
+ confirm:
subject: Kinnitustaotlus domeeni %{domain_name} kustutamiseks .ee registrist / Application for approval for deletion of %{domain_name}
+ forced:
+ subject: Kustutusmenetluse teade
diff --git a/spec/jobs/domain_expiration_email_job_spec.rb b/spec/jobs/domain_expire_email_job_spec.rb
similarity index 96%
rename from spec/jobs/domain_expiration_email_job_spec.rb
rename to spec/jobs/domain_expire_email_job_spec.rb
index ecc8c24df..3005edf8d 100644
--- a/spec/jobs/domain_expiration_email_job_spec.rb
+++ b/spec/jobs/domain_expire_email_job_spec.rb
@@ -1,6 +1,6 @@
require 'rails_helper'
-RSpec.describe DomainExpirationEmailJob do
+RSpec.describe DomainExpireEmailJob do
describe '#run' do
let(:domain) { instance_double(Domain) }
diff --git a/spec/mailers/delete_domain_mailer_spec.rb b/spec/mailers/delete_domain_mailer_spec.rb
deleted file mode 100644
index 3b80c8765..000000000
--- a/spec/mailers/delete_domain_mailer_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe DeleteDomainMailer do
- describe '#pending' do
- let(:domain) { instance_spy(Domain, name: 'test.com') }
- let(:old_registrant) { instance_spy(Registrant, email: 'registrant@test.com') }
- let(:domain_presenter) { instance_spy(DomainPresenter) }
- let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
- subject(:message) { described_class.pending(domain: domain, old_registrant: old_registrant) }
-
- before :example do
- expect(DomainPresenter).to receive(:new).and_return(domain_presenter)
- expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter)
- end
-
- it 'has sender' do
- expect(message.from).to eq(['noreply@internet.ee'])
- end
-
- it 'has old registrant email as a recipient' do
- expect(message.to).to match_array(['registrant@test.com'])
- end
-
- it 'has subject' do
- subject = 'Kinnitustaotlus domeeni test.com kustutamiseks .ee registrist' \
- ' / Application for approval for deletion of test.com'
-
- expect(message.subject).to eq(subject)
- end
-
- it 'has confirmation url' do
- allow(domain).to receive(:id).and_return(1)
- expect(domain).to receive(:registrant_verification_token).and_return('test')
- url = registrant_domain_delete_confirm_url(domain, token: 'test')
- expect(message.body.parts.first.decoded).to include(url)
- end
-
- it 'sends message' do
- expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
- end
- end
-end
diff --git a/spec/mailers/domain_delete_mailer_spec.rb b/spec/mailers/domain_delete_mailer_spec.rb
new file mode 100644
index 000000000..9e2d20a8a
--- /dev/null
+++ b/spec/mailers/domain_delete_mailer_spec.rb
@@ -0,0 +1,82 @@
+require 'rails_helper'
+
+RSpec.describe DomainDeleteMailer do
+ describe '#confirm' do
+ let(:domain) { instance_spy(Domain, name: 'test.com') }
+ let(:registrar) { instance_spy(Registrar) }
+ let(:registrant) { instance_spy(Registrant, email: 'registrant@test.com') }
+
+ let(:domain_presenter) { instance_spy(DomainPresenter) }
+ let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
+
+ subject(:message) { described_class.confirm(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)
+ end
+
+ it 'has sender' do
+ expect(message.from).to eq(['noreply@internet.ee'])
+ end
+
+ it 'has registrant\'s email as a recipient' do
+ expect(message.to).to match_array(['registrant@test.com'])
+ end
+
+ it 'has subject' do
+ subject = 'Kinnitustaotlus domeeni test.com kustutamiseks .ee registrist' \
+ ' / Application for approval for deletion of test.com'
+
+ expect(message.subject).to eq(subject)
+ end
+
+ it 'has confirm url' do
+ allow(domain).to receive(:id).and_return(1)
+ expect(domain).to receive(:registrant_verification_token).and_return('test')
+ url = registrant_domain_delete_confirm_url(domain, token: 'test')
+ expect(message.body.parts.first.decoded).to include(url)
+ end
+
+ it 'sends message' do
+ expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
+ end
+ end
+
+ describe '#forced' do
+ let(:domain) { instance_spy(Domain, name: 'test.com') }
+ let(:domain_presenter) { instance_spy(DomainPresenter) }
+ let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
+ let(:registrant_presenter) { instance_spy(RegistrantPresenter) }
+ subject(:message) { described_class.forced(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 recipient' do
+ expect(domain).to receive(:primary_contact_emails).and_return(['recipient@test.com'])
+ expect(message.to).to match_array(['recipient@test.com'])
+ end
+
+ it 'has valid subject' do
+ expect(message.subject).to eq('Kustutusmenetluse teade')
+ end
+
+ it 'sends message' do
+ expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
+ end
+ end
+end
diff --git a/spec/mailers/domain_mailer_spec.rb b/spec/mailers/domain_mailer_spec.rb
index e10826645..a3f4a42c7 100644
--- a/spec/mailers/domain_mailer_spec.rb
+++ b/spec/mailers/domain_mailer_spec.rb
@@ -1,34 +1,5 @@
require 'rails_helper'
RSpec.describe DomainMailer do
- describe '#force_delete' do
- let(:domain) { instance_spy(Domain, name: 'test.com') }
- let(:domain_presenter) { instance_spy(DomainPresenter) }
- let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
- let(:registrant_presenter) { instance_spy(RegistrantPresenter) }
- subject(:message) { described_class.force_delete(domain: domain) }
- 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 recipient' do
- expect(domain).to receive(:primary_contact_emails).and_return(['recipient@test.com'])
- expect(message.to).to match_array(['recipient@test.com'])
- end
-
- it 'has valid subject' do
- expect(message.subject).to eq('Kustutusmenetluse teade')
- 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 1dc691e7b..ef70f9649 100644
--- a/spec/models/domain_spec.rb
+++ b/spec/models/domain_spec.rb
@@ -805,26 +805,6 @@ RSpec.describe Domain, db: false do
end
end
- describe '#pending_delete!' do
- let(:domain) { described_class.new }
- let(:old_registrant) { instance_double(Registrant) }
- let(:message) { instance_double(Mail::Message) }
-
- before :example do
- expect(Registrant).to receive(:find).and_return(old_registrant)
- allow(domain).to receive(:registrant_verification_asked?).and_return(true)
- allow(domain).to receive(:save)
- end
-
- it 'sends notification email' do
- expect(DeleteDomainMailer).to receive(:pending)
- .with(domain: domain, old_registrant: old_registrant)
- .and_return(message)
- expect(message).to receive(:deliver)
- domain.pending_delete!
- end
- end
-
describe '#set_graceful_expired' do
let(:domain) { described_class.new }
@@ -877,46 +857,6 @@ RSpec.describe Domain, db: false do
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' }) }
@@ -924,4 +864,12 @@ RSpec.describe Domain, db: false do
expect(domain.new_registrant_email).to eq('test@test.com')
end
end
+
+ describe '#new_registrant_id' do
+ let(:domain) { described_class.new(pending_json: { new_registrant_id: 1 }) }
+
+ it 'returns new registrant\'s id' do
+ expect(domain.new_registrant_id).to eq(1)
+ end
+ end
end
diff --git a/spec/views/mailers/delete_domain_mailer/pending.html.erb_spec.rb b/spec/views/mailers/domain_delete_mailer/confirm.html.erb_spec.rb
similarity index 62%
rename from spec/views/mailers/delete_domain_mailer/pending.html.erb_spec.rb
rename to spec/views/mailers/domain_delete_mailer/confirm.html.erb_spec.rb
index e36208916..7d7776d0a 100644
--- a/spec/views/mailers/delete_domain_mailer/pending.html.erb_spec.rb
+++ b/spec/views/mailers/domain_delete_mailer/confirm.html.erb_spec.rb
@@ -1,11 +1,11 @@
require 'rails_helper'
-require_relative 'pending_shared'
+require_relative 'confirm_shared'
-RSpec.describe 'mailers/delete_domain_mailer/pending.html.erb' do
+RSpec.describe 'mailers/domain_delete_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'
end
- include_examples 'delete domain mailer pending'
+ include_examples 'domain delete mailer confirm'
end
diff --git a/spec/views/mailers/delete_domain_mailer/pending.text.erb_spec.rb b/spec/views/mailers/domain_delete_mailer/confirm.text.erb_spec.rb
similarity index 62%
rename from spec/views/mailers/delete_domain_mailer/pending.text.erb_spec.rb
rename to spec/views/mailers/domain_delete_mailer/confirm.text.erb_spec.rb
index 87aea70ab..b5f257b86 100644
--- a/spec/views/mailers/delete_domain_mailer/pending.text.erb_spec.rb
+++ b/spec/views/mailers/domain_delete_mailer/confirm.text.erb_spec.rb
@@ -1,11 +1,11 @@
require 'rails_helper'
-require_relative 'pending_shared'
+require_relative 'confirm_shared'
-RSpec.describe 'mailers/delete_domain_mailer/pending.text.erb' do
+RSpec.describe 'mailers/domain_delete_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'
end
- include_examples 'delete domain mailer pending'
+ include_examples 'domain delete mailer confirm'
end
diff --git a/spec/views/mailers/delete_domain_mailer/pending_shared.rb b/spec/views/mailers/domain_delete_mailer/confirm_shared.rb
similarity index 76%
rename from spec/views/mailers/delete_domain_mailer/pending_shared.rb
rename to spec/views/mailers/domain_delete_mailer/confirm_shared.rb
index 2b38eca85..960e5cf42 100644
--- a/spec/views/mailers/delete_domain_mailer/pending_shared.rb
+++ b/spec/views/mailers/domain_delete_mailer/confirm_shared.rb
@@ -1,13 +1,13 @@
require 'rails_helper'
-RSpec.shared_examples 'delete domain mailer pending' do
+RSpec.shared_examples 'domain delete mailer confirm' do
let(:domain) { instance_spy(DomainPresenter) }
let(:lang_count) { 2 }
before :example do
assign(:domain, domain)
assign(:registrar, nil)
- assign(:verification_url, 'test verification url')
+ assign(:confirm_url, 'test confirm url')
end
it 'has registrar info in estonian' do
@@ -27,9 +27,9 @@ RSpec.shared_examples 'delete domain mailer pending' do
expect(rendered).to have_text('test domain name', count: mention_count)
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
end
diff --git a/spec/views/mailers/domain_mailer/force_delete.html.erb_spec.rb b/spec/views/mailers/domain_delete_mailer/forced.html.erb_spec.rb
similarity index 68%
rename from spec/views/mailers/domain_mailer/force_delete.html.erb_spec.rb
rename to spec/views/mailers/domain_delete_mailer/forced.html.erb_spec.rb
index 462211b78..4f38b7743 100644
--- a/spec/views/mailers/domain_mailer/force_delete.html.erb_spec.rb
+++ b/spec/views/mailers/domain_delete_mailer/forced.html.erb_spec.rb
@@ -1,12 +1,12 @@
require 'rails_helper'
-require_relative 'force_delete_shared'
+require_relative 'forced_shared'
-RSpec.describe 'mailers/domain_mailer/force_delete.html.erb' do
+RSpec.describe 'mailers/domain_delete_mailer/forced.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/registrar/_registrar.ru.html' => 'test registrar russian'
end
- include_examples 'domain mailer force delete'
+ include_examples 'domain delete mailer forced'
end
diff --git a/spec/views/mailers/domain_mailer/force_delete.text.erb_spec.rb b/spec/views/mailers/domain_delete_mailer/forced.text.erb_spec.rb
similarity index 68%
rename from spec/views/mailers/domain_mailer/force_delete.text.erb_spec.rb
rename to spec/views/mailers/domain_delete_mailer/forced.text.erb_spec.rb
index 6aaf08820..a53c5beca 100644
--- a/spec/views/mailers/domain_mailer/force_delete.text.erb_spec.rb
+++ b/spec/views/mailers/domain_delete_mailer/forced.text.erb_spec.rb
@@ -1,12 +1,12 @@
require 'rails_helper'
-require_relative 'force_delete_shared'
+require_relative 'forced_shared'
-RSpec.describe 'mailers/domain_mailer/force_delete.text.erb' do
+RSpec.describe 'mailers/domain_delete_mailer/forced.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/registrar/_registrar.ru.text' => 'test registrar russian'
end
- include_examples 'domain mailer force delete'
+ include_examples 'domain delete mailer forced'
end
diff --git a/spec/views/mailers/domain_mailer/force_delete_shared.rb b/spec/views/mailers/domain_delete_mailer/forced_shared.rb
similarity index 95%
rename from spec/views/mailers/domain_mailer/force_delete_shared.rb
rename to spec/views/mailers/domain_delete_mailer/forced_shared.rb
index 36c407bb3..b8e696b81 100644
--- a/spec/views/mailers/domain_mailer/force_delete_shared.rb
+++ b/spec/views/mailers/domain_delete_mailer/forced_shared.rb
@@ -1,6 +1,6 @@
require 'rails_helper'
-RSpec.shared_examples 'domain mailer force delete' do
+RSpec.shared_examples 'domain delete mailer forced' do
let(:domain) { instance_spy(DomainPresenter) }
let(:registrar) { instance_spy(RegistrarPresenter) }
let(:registrant) { instance_spy(RegistrantPresenter) }