Skip to content

Commit

Permalink
Send reminders about visible issues only (#25713).
Browse files Browse the repository at this point in the history
Patch by Felix Schäfer.

git-svn-id: http://svn.redmine.org/redmine/trunk@16557 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
jplang committed May 13, 2017
1 parent 6543d73 commit 0f09f16
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/models/mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,10 @@ def self.reminders(options={})
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

Expand Down
19 changes: 19 additions & 0 deletions test/unit/mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,25 @@ def test_reminders_with_version_option
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_security_notification
set_language_if_valid User.find(1).language
with_settings :emails_footer => "footer without link" do
Expand Down

0 comments on commit 0f09f16

Please sign in to comment.