Updated domain registrant updater mailer spec

This commit is contained in:
Priit Tark 2015-05-14 15:32:27 +03:00
parent ab6f59c09e
commit 99eeeae89f
3 changed files with 7 additions and 5 deletions

View file

@ -1,17 +1,17 @@
class DomainMailer < ApplicationMailer
def registrant_updated(domain)
return if Rails.env.production? ? false : !TEST_EMAILS.include?(domain.registrant_email)
@domain = domain
return if Rails.env.production? ? false : !TEST_EMAILS.include?(@domain.registrant_email)
# turn on delivery on specific request only, thus rake tasks does not deliver anything
return if domain.deliver_emails != true
if domain.registrant_verification_token.blank?
return if @domain.deliver_emails != true
if @domain.registrant_verification_token.blank?
logger.warn "EMAIL DID NOT DELIVERED: registrant_verification_token is missing for #{@domain.name}"
return
end
@old_registrant = Registrant.find(domain.registrant_id_was)
@old_registrant = Registrant.find(@domain.registrant_id_was)
@verification_url = "#{ENV['registrant_url']}/etc/"
@domain = domain
mail(to: @old_registrant.email,
subject: "#{I18n.t(:domain_registrant_update_subject, name: @domain.name)} [#{@domain.name}]")
end

View file

@ -63,6 +63,7 @@ class Domain < ActiveRecord::Base
domain_statuses.build(value: DomainStatus::PENDING_UPDATE)
DomainMailer.registrant_updated(self).deliver_now
end
true
end
before_save :touch_always_version

View file

@ -31,6 +31,7 @@ describe DomainMailer do
@new_registrant = Fabricate(:registrant, email: 'test@example.org')
@domain = Fabricate(:domain, registrant: @registrant)
@domain.deliver_emails = true
@domain.registrant_verification_token = '123'
@domain.registrant = @new_registrant
@mail = DomainMailer.registrant_updated(@domain)
end