Expected false to be truthy

This commit is contained in:
Karel Pičman 2023-11-15 13:25:36 +01:00
parent 763871577c
commit 8842fd69ea
2 changed files with 4 additions and 12 deletions

View File

@ -166,23 +166,17 @@ class DmsfMailer < Mailer
# force_notification = true => approval workflow's notifications
def self.get_notify_users(project, file, force_notification: false)
puts ">>> self.get_notify_users"
return [] unless project.active?
puts ">>> ok1"
# Notifications
if (force_notification && Setting.notified_events.include?('dmsf_workflow_plural')) ||
(Setting.notified_events.include?('dmsf_legacy_notifications') && file&.notify?)
puts ">>> ok2"
notify_members = project.members.active.select do |notify_member|
notify_user = notify_member.user
if notify_user == User.current && notify_user.pref.no_self_notified
puts ">>> nok1"
false
elsif notify_member.dmsf_mail_notification.nil?
puts ">>> notify_member.mail_notification: #{notify_member.dmsf_mail_notification}"
case notify_user.mail_notification
when 'all'
puts ">>> ok3"
true
when 'selected'
notify_member.mail_notification?
@ -193,7 +187,6 @@ class DmsfMailer < Mailer
when 'only_assigned'
file.assigned? notify_user
else
puts ">>> nok2"
false
end
else

View File

@ -35,6 +35,10 @@ class DmsfMailerTest < RedmineDmsf::Test::UnitTest
ActionMailer::Base.deliveries.clear
Setting.plain_text_mail = '0'
Setting.default_language = 'en'
# Notification
m1 = Member.find 1
m1.dmsf_mail_notification = true
m1.save
end
def test_files_updated
@ -104,12 +108,7 @@ class DmsfMailerTest < RedmineDmsf::Test::UnitTest
end
def test_get_notify_users
m1 = Member.find 1
m1.dmsf_mail_notification = true
m1.save
with_settings notified_events: ['dmsf_legacy_notifications'] do
puts ">>> Setting.notified_events: #{Setting.notified_events}"
puts ">>> @file1.notify?: #{@file1.notify?}"
users = DmsfMailer.get_notify_users(@project1, @file1)
assert users.present?
end