From 726231c4e6c87a4f35aac13dc0efe13aa623effa Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Tue, 28 Jul 2015 12:10:28 +0300 Subject: [PATCH] Refactor domain mailers pending updates #2804 --- app/mailers/domain_mailer.rb | 13 ++++++++----- app/models/domain.rb | 2 +- ... pending_update_old_registrant_request.html.erb} | 0 ... pending_update_old_registrant_request.text.erb} | 0 config/locales/en.yml | 4 ++-- spec/mailers/domain_mailer_spec.rb | 6 +++--- 6 files changed, 14 insertions(+), 11 deletions(-) rename app/views/mailers/domain_mailer/{registrant_pending_updated.html.erb => pending_update_old_registrant_request.html.erb} (100%) rename app/views/mailers/domain_mailer/{registrant_pending_updated.text.erb => pending_update_old_registrant_request.text.erb} (100%) diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index f7de5171a..822d4a22f 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -1,5 +1,5 @@ class DomainMailer < ApplicationMailer - def registrant_pending_updated(domain) + def pending_update_old_registrant_request(domain) @domain = domain return if delivery_off?(@domain) @@ -20,7 +20,8 @@ class DomainMailer < ApplicationMailer return if whitelist_blocked?(@old_registrant.email) mail(to: @old_registrant.email, - subject: "#{I18n.t(:domain_registrant_pending_updated_subject, name: @domain.name)} [#{@domain.name}]") + subject: "#{I18n.t(:pending_update_old_registrant_request_subject, + name: @domain.name)} [#{@domain.name}]") end def pending_update_new_registrant_notification(domain) @@ -42,7 +43,7 @@ class DomainMailer < ApplicationMailer return if whitelist_blocked?(@new_registrant.email) mail(to: @new_registrant.email, - subject: "#{I18n.t(:domain_pending_update_new_registrant_notification_subject, + subject: "#{I18n.t(:pending_update_new_registrant_notification_subject, name: @domain.name)} [#{@domain.name}]") end @@ -52,7 +53,8 @@ class DomainMailer < ApplicationMailer return if whitelist_blocked?(@domain.registrant_email) mail(to: @domain.registrant_email, - subject: "#{I18n.t(:domain_registrant_updated, name: @domain.name)} [#{@domain.name}]") + subject: "#{I18n.t(:domain_registrant_updated, + name: @domain.name)} [#{@domain.name}]") end def pending_deleted(domain) @@ -76,6 +78,7 @@ class DomainMailer < ApplicationMailer return if whitelist_blocked?(@old_registrant.email) mail(to: @old_registrant.email, - subject: "#{I18n.t(:domain_pending_deleted_subject, name: @domain.name)} [#{@domain.name}]") + subject: "#{I18n.t(:domain_pending_deleted_subject, + name: @domain.name)} [#{@domain.name}]") end end diff --git a/app/models/domain.rb b/app/models/domain.rb index cd9f61e89..d77587d40 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -360,7 +360,7 @@ class Domain < ActiveRecord::Base asked_at = registrant_verification_asked_at changes_cache = changes - DomainMailer.registrant_pending_updated(self).deliver_now + DomainMailer.pending_update_old_registrant_request(self).deliver_now DomainMailer.pending_update_new_registrant_notification(self).deliver_now reload # revert back to original diff --git a/app/views/mailers/domain_mailer/registrant_pending_updated.html.erb b/app/views/mailers/domain_mailer/pending_update_old_registrant_request.html.erb similarity index 100% rename from app/views/mailers/domain_mailer/registrant_pending_updated.html.erb rename to app/views/mailers/domain_mailer/pending_update_old_registrant_request.html.erb diff --git a/app/views/mailers/domain_mailer/registrant_pending_updated.text.erb b/app/views/mailers/domain_mailer/pending_update_old_registrant_request.text.erb similarity index 100% rename from app/views/mailers/domain_mailer/registrant_pending_updated.text.erb rename to app/views/mailers/domain_mailer/pending_update_old_registrant_request.text.erb diff --git a/config/locales/en.yml b/config/locales/en.yml index a25260496..f083a40e3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -777,8 +777,8 @@ 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' - domain_registrant_pending_updated_subject: "Kinnitustaotlus domeeni %{name} registreerija vahetuseks / Application for approval for registrant chache of %{name}" - domain_pending_update_new_registrant_notification_subject: "Domeeni %{name} registreerija vahetus protseduur on algatatud / %{name} registrant change" + pending_update_old_registrant_request_subject: "Kinnitustaotlus domeeni %{name} registreerija vahetuseks / Application for approval for registrant chache of %{name}" + pending_update_new_registrant_notification_subject: "Domeeni %{name} registreerija vahetus protseduur on algatatud / %{name} registrant change" domain_pending_deleted_subject: "Kinnitustaotlus domeeni %{name} kustutamiseks .ee registrist / Application for approval for deletion of %{name}" whois: WHOIS login_failed_check_id_card: 'Log in failed, check ID card' diff --git a/spec/mailers/domain_mailer_spec.rb b/spec/mailers/domain_mailer_spec.rb index a0701c1bd..a78e4d030 100644 --- a/spec/mailers/domain_mailer_spec.rb +++ b/spec/mailers/domain_mailer_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' describe DomainMailer do - describe 'registrant changed notification when delivery turned off' do + describe 'registrant change request for old registrant when delivery turned off' do before :all do @registrant = Fabricate(:registrant, email: 'test@example.com') @domain = Fabricate(:domain, registrant: @registrant) - @mail = DomainMailer.registrant_pending_updated(@domain) + @mail = DomainMailer.pending_update_old_registrant_request(@domain) end it 'should not render email subject' do @@ -34,7 +34,7 @@ describe DomainMailer do @domain.registrant_verification_token = '123' @domain.registrant_verification_asked_at = Time.zone.now @domain.registrant = @new_registrant - @mail = DomainMailer.registrant_pending_updated(@domain) + @mail = DomainMailer.pending_update_old_registrant_request(@domain) end it 'should render email subject' do