diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index 11789f1d3..e7ecb9b17 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -26,8 +26,9 @@ class DomainMailer < ApplicationMailer name: @domain.name)} [#{@domain.name}]") end - def pending_update_notification_for_new_registrant(domain_id, should_deliver) + def pending_update_notification_for_new_registrant(domain_id, old_registrant_id, should_deliver) @domain = Domain.find_by(id: domain_id) + @old_registrant = Registrant.find(old_registrant_id) return unless @domain return if delivery_off?(@domain, should_deliver) @@ -42,7 +43,6 @@ class DomainMailer < ApplicationMailer end @new_registrant = @domain.registrant # NB! new registrant at this point - @old_registrant = Registrant.find(@domain.registrant_id_was) return if whitelist_blocked?(@new_registrant.email) mail(to: format(@new_registrant.email), diff --git a/app/models/domain.rb b/app/models/domain.rb index ca1dc762e..6a8544b63 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -430,7 +430,7 @@ class Domain < ActiveRecord::Base new_registrant_name = registrant.name DomainMailer.pending_update_request_for_old_registrant(id, old_registrant_id, deliver_emails).deliver - DomainMailer.pending_update_notification_for_new_registrant(id, deliver_emails).deliver + DomainMailer.pending_update_notification_for_new_registrant(id, old_registrant_id, deliver_emails).deliver reload # revert back to original diff --git a/spec/mailers/domain_mailer_spec.rb b/spec/mailers/domain_mailer_spec.rb index 3615fff29..050cc344a 100644 --- a/spec/mailers/domain_mailer_spec.rb +++ b/spec/mailers/domain_mailer_spec.rb @@ -71,7 +71,7 @@ describe DomainMailer do @domain.registrant_verification_token = '123' @domain.registrant_verification_asked_at = Time.zone.now @domain.registrant = @new_registrant - @mail = DomainMailer.pending_update_notification_for_new_registrant(@domain.id, deliver_emails) + @mail = DomainMailer.pending_update_notification_for_new_registrant(@domain.id, @registrant.id, deliver_emails) end it 'should render email subject' do @@ -100,7 +100,7 @@ describe DomainMailer do @domain.registrant_verification_token = '123' @domain.registrant_verification_asked_at = Time.zone.now @domain.registrant = @new_registrant - @mail = DomainMailer.pending_update_notification_for_new_registrant(@domain.id, deliver_emails) + @mail = DomainMailer.pending_update_notification_for_new_registrant(@domain.id, @registrant.id, deliver_emails) end it 'should render email subject' do