Refactor domain mailers pending updates #2804

This commit is contained in:
Priit Tark 2015-07-28 12:10:28 +03:00
parent 8536ac2d6f
commit 726231c4e6
6 changed files with 14 additions and 11 deletions

View file

@ -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

View file

@ -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

View file

@ -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'

View file

@ -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