summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-05-27 07:40:24 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-05-27 07:40:24 +0000
commitd54ede781b60207dc9163e5953c04a52bac82c42 (patch)
tree05893ddbc91890b624c12e597bdf234ee8702bfc
parent313706276c2478d03bd6d22c9495f3bbef292ec8 (diff)
downloadredmine-d54ede781b60207dc9163e5953c04a52bac82c42.tar.gz
redmine-d54ede781b60207dc9163e5953c04a52bac82c42.zip
Merged r16557 (#25713).
git-svn-id: http://svn.redmine.org/redmine/branches/3.2-stable@16567 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/mailer.rb5
-rw-r--r--test/unit/mailer_test.rb19
2 files changed, 23 insertions, 1 deletions
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 0e51a095d..95a76a23e 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -362,7 +362,10 @@ class Mailer < ActionMailer::Base
end
issues_by_assignee.each do |assignee, issues|
- reminder(assignee, issues, days).deliver if assignee.is_a?(User) && assignee.active?
+ if assignee.is_a?(User) && assignee.active? && issues.present?
+ visible_issues = issues.select {|i| i.visible?(assignee)}
+ reminder(assignee, visible_issues, days).deliver if visible_issues.present?
+ end
end
end
diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb
index 93b7a8196..cd8489360 100644
--- a/test/unit/mailer_test.rb
+++ b/test/unit/mailer_test.rb
@@ -666,6 +666,25 @@ class MailerTest < ActiveSupport::TestCase
end
end
+ def test_reminders_should_only_include_issues_the_user_can_see
+ with_settings :default_language => 'en' do
+ user = User.find(3)
+ member = Member.create!(:project_id => 2, :principal => user, :role_ids => [1])
+ Issue.create!(:project_id => 2, :tracker_id => 1, :status_id => 1,
+ :subject => 'Issue dlopper should not see', :assigned_to_id => 3,
+ :due_date => 5.days.from_now,
+ :author_id => 2)
+ member.destroy
+ ActionMailer::Base.deliveries.clear
+
+ Mailer.reminders(:days => 42)
+ assert_equal 1, ActionMailer::Base.deliveries.size
+ mail = last_email
+ assert mail.bcc.include?('dlopper@somenet.foo')
+ assert_mail_body_no_match 'Issue dlopper should not see', mail
+ end
+ end
+
def test_mailer_should_not_change_locale
# Set current language to italian
set_language_if_valid 'it'