Story#107821878 - pending_deleted gets new registrant_id too

This commit is contained in:
Vladimir Krylov 2015-11-30 15:37:17 +02:00
parent 44ae8fd350
commit 4fa286d0b0
3 changed files with 5 additions and 6 deletions

View file

@ -106,8 +106,9 @@ class DomainMailer < ApplicationMailer
name: @domain.name)} [#{@domain.name}]") name: @domain.name)} [#{@domain.name}]")
end end
def pending_deleted(domain_id, should_deliver) def pending_deleted(domain_id, old_registrant_id, should_deliver)
@domain = Domain.find_by(id: domain_id) @domain = Domain.find_by(id: domain_id)
@old_registrant = Registrant.find(old_registrant_id)
return unless @domain return unless @domain
return if delivery_off?(@domain, should_deliver) return if delivery_off?(@domain, should_deliver)
@ -121,8 +122,6 @@ class DomainMailer < ApplicationMailer
return return
end end
@old_registrant = Registrant.find(@domain.registrant_id_was)
confirm_path = "#{ENV['registrant_url']}/registrant/domain_delete_confirms" confirm_path = "#{ENV['registrant_url']}/registrant/domain_delete_confirms"
@verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}" @verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"

View file

@ -490,7 +490,7 @@ class Domain < ActiveRecord::Base
pending_delete_confirmation! pending_delete_confirmation!
save(validate: false) # should check if this did succeed save(validate: false) # should check if this did succeed
DomainMailer.pending_deleted(id, deliver_emails).deliver DomainMailer.pending_deleted(id, registrant_id_was, deliver_emails).deliver
end end
def pricelist(operation, period_i = nil, unit = nil) def pricelist(operation, period_i = nil, unit = nil)

View file

@ -202,7 +202,7 @@ describe DomainMailer do
before :all do before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com') @registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, registrant: @registrant) @domain = Fabricate(:domain, registrant: @registrant)
@mail = DomainMailer.pending_deleted(@domain.id, deliver_emails) @mail = DomainMailer.pending_deleted(@domain.id, @registrant.id, deliver_emails)
end end
it 'should not render email subject' do it 'should not render email subject' do
@ -229,7 +229,7 @@ describe DomainMailer do
@domain.deliver_emails = true @domain.deliver_emails = true
@domain.registrant_verification_token = '123' @domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now @domain.registrant_verification_asked_at = Time.zone.now
@mail = DomainMailer.pending_deleted(@domain.id, deliver_emails) @mail = DomainMailer.pending_deleted(@domain.id, @registrant.id, deliver_emails)
end end
it 'should render email subject' do it 'should render email subject' do