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)
|
def prevent_delivery?(mail)
|
||||||
return false if mail[BYPASS_UNVERIFIED_MAIL_PROTECTION].present?
|
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)
|
user = User.find_by(email: mail.to.first)
|
||||||
return user.unverified_email? if user.present?
|
return user.unverified_email? if user.present?
|
||||||
|
|
|
@ -2,8 +2,8 @@ RSpec.describe BalancerDeliveryMethod do
|
||||||
class ExampleMailer < ApplicationMailer
|
class ExampleMailer < ApplicationMailer
|
||||||
include BalancedDeliveryConcern
|
include BalancedDeliveryConcern
|
||||||
|
|
||||||
def greet(name, bypass_unverified_mail_protection: true)
|
def greet(name, bypass_unverified_mail_protection: true, **mail_args)
|
||||||
mail(to: name, from: "smtp_from", body: "Hello #{name}")
|
mail(to: name, from: "smtp_from", body: "Hello #{name}", **mail_args)
|
||||||
|
|
||||||
bypass_unverified_mail_protection! if bypass_unverified_mail_protection
|
bypass_unverified_mail_protection! if bypass_unverified_mail_protection
|
||||||
end
|
end
|
||||||
|
@ -202,6 +202,13 @@ RSpec.describe BalancerDeliveryMethod do
|
||||||
it { expect(mail).to have_been_delivered_using(MockSmtp) }
|
it { expect(mail).to have_been_delivered_using(MockSmtp) }
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
# Helpers
|
# Helpers
|
||||||
|
|
Loading…
Reference in a new issue