FIX: "confirm new email" emails were failing for EmailChangeRequest records with blank requested_by_user_id field (#12579)
This commit is contained in:
parent
61860098d9
commit
3db08c073b
|
@ -13,7 +13,7 @@ class EmailChangeRequest < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def requested_by_admin?
|
def requested_by_admin?
|
||||||
self.requested_by.admin? && !self.requested_by_self?
|
self.requested_by&.admin? && !self.requested_by_self?
|
||||||
end
|
end
|
||||||
|
|
||||||
def requested_by_self?
|
def requested_by_self?
|
||||||
|
|
|
@ -321,6 +321,15 @@ describe Jobs::UserEmail do
|
||||||
expect(mail.body).not_to include("This email change was requested by a site admin.")
|
expect(mail.body).not_to include("This email change was requested by a site admin.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when requested_by record is not present" do
|
||||||
|
let(:requested_by) { nil }
|
||||||
|
it "passes along false for the requested_by_admin param which changes the wording in the email" do
|
||||||
|
Jobs::UserEmail.new.execute(type: :confirm_new_email, user_id: user.id, email_token: email_token.token)
|
||||||
|
mail = ActionMailer::Base.deliveries.first
|
||||||
|
expect(mail.body).not_to include("This email change was requested by a site admin.")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "post" do
|
context "post" do
|
||||||
|
|
Loading…
Reference in New Issue