##// END OF EJS Templates
Fixed that the reminder email excludes issues assigned to groups (#11723)....
Jean-Philippe Lang -
r10152:197a14a82e3e
parent child
Show More
@@ -327,7 +327,7 class Mailer < ActionMailer::Base
327 327 # * :days => how many days in the future to remind about (defaults to 7)
328 328 # * :tracker => id of tracker for filtering issues (defaults to all trackers)
329 329 # * :project => id or identifier of project to process (defaults to all projects)
330 # * :users => array of user ids who should be reminded
330 # * :users => array of user/group ids who should be reminded
331 331 def self.reminders(options={})
332 332 days = options[:days] || 7
333 333 project = options[:project] ? Project.find(options[:project]) : nil
@@ -343,6 +343,15 class Mailer < ActionMailer::Base
343 343 scope = scope.scoped(:conditions => {:tracker_id => tracker.id}) if tracker
344 344
345 345 issues_by_assignee = scope.all(:include => [:status, :assigned_to, :project, :tracker]).group_by(&:assigned_to)
346 issues_by_assignee.keys.each do |assignee|
347 if assignee.is_a?(Group)
348 assignee.users.each do |user|
349 issues_by_assignee[user] ||= []
350 issues_by_assignee[user] += issues_by_assignee[assignee]
351 end
352 end
353 end
354
346 355 issues_by_assignee.each do |assignee, issues|
347 356 reminder(assignee, issues, days).deliver if assignee.is_a?(User) && assignee.active?
348 357 end
@@ -22,7 +22,7 Available options:
22 22 * days => number of days to remind about (defaults to 7)
23 23 * tracker => id of tracker (defaults to all trackers)
24 24 * project => id or identifier of project (defaults to all projects)
25 * users => comma separated list of user ids who should be reminded
25 * users => comma separated list of user/group ids who should be reminded
26 26
27 27 Example:
28 28 rake redmine:send_reminders days=7 users="1,23, 56" RAILS_ENV="production"
@@ -508,6 +508,27 class MailerTest < ActiveSupport::TestCase
508 508 assert_mail_body_match 'Bug #3: Error 281 when updating a recipe', mail
509 509 end
510 510
511 def test_reminder_should_include_issues_assigned_to_groups
512 with_settings :default_language => 'en' do
513 group = Group.generate!
514 group.users << User.find(2)
515 group.users << User.find(3)
516
517 Issue.create!(:project_id => 1, :tracker_id => 1, :status_id => 1,
518 :subject => 'Assigned to group', :assigned_to => group,
519 :due_date => 5.days.from_now,
520 :author_id => 2)
521 ActionMailer::Base.deliveries.clear
522
523 Mailer.reminders(:days => 7)
524 assert_equal 2, ActionMailer::Base.deliveries.size
525 assert_equal %w(dlopper@somenet.foo jsmith@somenet.foo), ActionMailer::Base.deliveries.map(&:bcc).flatten.sort
526 ActionMailer::Base.deliveries.each do |mail|
527 assert_mail_body_match 'Assigned to group', mail
528 end
529 end
530 end
531
511 532 def test_mailer_should_not_change_locale
512 533 Setting.default_language = 'en'
513 534 # Set current language to italian
General Comments 0
You need to be logged in to leave comments. Login now