From f9b2d2a20280f6cf41e99be9090f2a1c007b534c Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 30 Nov 2015 13:12:51 +0200 Subject: [PATCH] Story#107821878 - manage old registrar --- app/mailers/domain_mailer.rb | 5 ++--- app/models/domain.rb | 2 +- spec/mailers/domain_mailer_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index a149ff2ed..11789f1d3 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -1,8 +1,9 @@ class DomainMailer < ApplicationMailer include Que::Mailer - def pending_update_request_for_old_registrant(domain_id, should_deliver) + def pending_update_request_for_old_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) @@ -16,8 +17,6 @@ class DomainMailer < ApplicationMailer return end - @old_registrant = Registrant.find(@domain.registrant_id_was) - confirm_path = "#{ENV['registrant_url']}/registrant/domain_update_confirms" @verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}" diff --git a/app/models/domain.rb b/app/models/domain.rb index 6730497e9..def2926cf 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -428,7 +428,7 @@ class Domain < ActiveRecord::Base new_registrant_email = registrant.email new_registrant_name = registrant.name - DomainMailer.pending_update_request_for_old_registrant(id, deliver_emails).deliver + DomainMailer.pending_update_request_for_old_registrant(id, registrant_id_was, deliver_emails).deliver DomainMailer.pending_update_notification_for_new_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 37605a668..3615fff29 100644 --- a/spec/mailers/domain_mailer_spec.rb +++ b/spec/mailers/domain_mailer_spec.rb @@ -9,7 +9,7 @@ describe DomainMailer do before :all do @registrant = Fabricate(:registrant, email: 'test@example.com') @domain = Fabricate(:domain, registrant: @registrant) - @mail = DomainMailer.pending_update_request_for_old_registrant(@domain.id, deliver_emails) + @mail = DomainMailer.pending_update_request_for_old_registrant(@domain.id, @registrant.id,deliver_emails) end it 'should not render email subject' do @@ -38,7 +38,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_request_for_old_registrant(@domain.id, deliver_emails) + @mail = DomainMailer.pending_update_request_for_old_registrant(@domain.id, @registrant.id, deliver_emails) end it 'should render email subject' do