fix(mailer): fix delivery prevented with bcc
This commit is contained in:
parent
395967e0a1
commit
ec269a568c
2 changed files with 10 additions and 2 deletions
|
@ -45,6 +45,7 @@ class BalancerDeliveryMethod
|
|||
|
||||
def prevent_delivery?(mail)
|
||||
return false if mail[BYPASS_UNVERIFIED_MAIL_PROTECTION].present?
|
||||
return false if mail.to.blank? # bcc list
|
||||
|
||||
user = User.find_by(email: mail.to.first)
|
||||
return user.unverified_email? if user.present?
|
||||
|
|
|
@ -2,8 +2,8 @@ RSpec.describe BalancerDeliveryMethod do
|
|||
class ExampleMailer < ApplicationMailer
|
||||
include BalancedDeliveryConcern
|
||||
|
||||
def greet(name, bypass_unverified_mail_protection: true)
|
||||
mail(to: name, from: "smtp_from", body: "Hello #{name}")
|
||||
def greet(name, bypass_unverified_mail_protection: true, **mail_args)
|
||||
mail(to: name, from: "smtp_from", body: "Hello #{name}", **mail_args)
|
||||
|
||||
bypass_unverified_mail_protection! if bypass_unverified_mail_protection
|
||||
end
|
||||
|
@ -202,6 +202,13 @@ RSpec.describe BalancerDeliveryMethod do
|
|||
it { expect(mail).to have_been_delivered_using(MockSmtp) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there are only bcc recipients' do
|
||||
let(:bypass_unverified_mail_protection) { false }
|
||||
let(:mail) { ExampleMailer.greet(nil, bypass_unverified_mail_protection: false, bcc: ["'u@a.com'"]) }
|
||||
|
||||
it { expect(mail).to have_been_delivered_using(MockSmtp) }
|
||||
end
|
||||
end
|
||||
|
||||
# Helpers
|
||||
|
|
Loading…
Reference in a new issue