DEV: Remove the use of stubs and mocks in Jobs::UserEmail tests.

We can only be sure that an email is sent when we get a mailer in
`ActionMailer::Deliveries`. A couple of tests were actually incorrect
because it didn't flow through our email sender where there are more
conditions in determining whether an email is sent or not.
This commit is contained in:
Guo Xiang Tan
2019-03-12 09:39:16 +08:00
parent 32bae48fd3
commit 34b29f62db
3 changed files with 134 additions and 57 deletions

View File

@@ -21,8 +21,13 @@ module Email
@user = user
end
def send
return if SiteSetting.disable_emails == "yes" && @email_type.to_s != "admin_login"
def send(is_critical: false)
if SiteSetting.disable_emails == "yes" &&
@email_type.to_s != "admin_login" &&
!is_critical
return
end
return if ActionMailer::Base::NullMail === @message
return if ActionMailer::Base::NullMail === (@message.message rescue nil)