Feature #29771 » 29771-reminders-order-due-date.patch
| app/models/mailer.rb | ||
|---|---|---|
|
include Roadie::Rails::Automatic
|
||
|
# Overrides ActionMailer::Base#process in order to set the recipient as the current user
|
||
|
# and his language as the default locale.
|
||
|
# and his language as the default locale.
|
||
|
# The first argument of all actions of this Mailer must be a User (the recipient),
|
||
|
# otherwise an ArgumentError is raised.
|
||
|
def process(action, *args)
|
||
| ... | ... | |
|
issues_by_assignee.each do |assignee, issues|
|
||
|
if assignee.is_a?(User) && assignee.active? && issues.present?
|
||
|
visible_issues = issues.select {|i| i.visible?(assignee)}
|
||
|
visible_issues.sort!{|a, b| (b.due_date <=> a.due_date).nonzero? || (a.id <=> b.id)}
|
||
|
reminder(assignee, visible_issues, days).deliver_later if visible_issues.present?
|
||
|
end
|
||
|
end
|
||
| test/unit/mailer_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def test_reminders_order_descending_on_due_date
|
||
|
with_settings :default_language => 'en' do
|
||
|
user = User.find(2)
|
||
|
issues = []
|
||
|
issues << Issue.generate!(:assigned_to => user, :due_date => 5.days.from_now)
|
||
|
issues << Issue.generate!(:assigned_to => user, :due_date => 5.days.from_now)
|
||
|
issues << Issue.generate!(:assigned_to => user, :due_date => 6.days.from_now)
|
||
|
issues << Issue.generate!(:assigned_to => user, :due_date => 6.days.from_now)
|
||
|
issues.sort!{|a, b| (b.due_date <=> a.due_date).nonzero? || (a.id <=> b.id)}
|
||
|
ActionMailer::Base.deliveries.clear
|
||
|
Mailer.reminders(:days => 7, :users => [user.id])
|
||
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||
|
mail = last_email
|
||
|
mailbody_issues = mail_body(mail).split(/\r\n/).select{|row| /^\*/ =~ row}
|
||
|
mailbody_issues.collect!{|row| /^\*.+#(\d+):/ =~ row; $1.to_i rescue nil}
|
||
|
assert_equal issues.collect(&:id), mailbody_issues
|
||
|
end
|
||
|
end
|
||
|
def test_security_notification
|
||
|
set_language_if_valid User.find(1).language
|
||
|
with_settings :emails_footer => "footer without link" do
|
||
| ... | ... | |
|
# Send an email to a french user
|
||
|
user = User.find(1)
|
||
|
user.update_attribute :language, 'fr'
|
||
|
|
||
|
Mailer.deliver_account_activated(user)
|
||
|
mail = last_email
|
||
|
assert_mail_body_match 'Votre compte', mail
|
||