Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alert email subject in the receivers language #8469

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

andersjl
Copy link
Contributor

Issue #5164 PR candidate

Relevant issue(s)

Fixes #5164.

What does this do?

Automatic email alerts are sent with the subject localized with the receiving user's locale.

Why was this needed?

Needed to ensure that the receiving user understands the subject line.

Implementation notes

User mails are sent with ApplicationMailer#mail_user. The change consists of requiring the subject: arg to mail_user to be a proc, and running the proc using the locale of the user arg.

All other changes are straightforward rewrites of the 26 other methods that call mail_user, and corresponding tests.

Notes to reviewer

Below is a list of the affected methods, where the corresponding tests are, and why some tests are not changed.

app/mailers/alaveteli_pro/embargo_mailer.rb
  expiring_alert(user, info_requests)
    test: spec/mailers/alaveteli_pro/embargo_mailer_spec.rb:124/160
  expired_alert(user, info_requests)
    test: spec/mailers/alaveteli_pro/embargo_mailer_spec.rb:278/314
app/mailers/alaveteli_pro/subscription_mailer.rb
  payment_failed(user)
    test: spec/mailers/alaveteli_pro/subscription_mailer_spec.rb:35
app/mailers/contact_mailer.rb
  user_message(from_user, recipient_user, from_user_url, subject, message)
    No new functionality to test
  from_admin_message(recipient_name, recipient_email, subject, message)
    No new functionality to test
app/mailers/info_request_batch_mailer.rb
  batch_sent(info_request_batch, unrequestable, user)
    test: spec/mailers/info_request_batch_mailer_spec.rb:26
app/mailers/notification_mailer.rb
  daily_summary(user, notifications)
    test: spec/mailers/notification_mailer_spec.rb:386
  response_notification(notification)
    test: spec/mailers/notification_mailer_spec.rb:470
  embargo_expiring_notification(notification)
    test: spec/mailers/notification_mailer_spec.rb:571
  expire_embargo_notification(notification)
    test: spec/mailers/notification_mailer_spec.rb:654
  overdue_notification(notification)
    test: spec/mailers/notification_mailer_spec.rb:733
  very_overdue_notification(notification)
    test: spec/mailers/notification_mailer_spec.rb:816
app/mailers/request_mailer.rb
  new_response(info_request, incoming_message)
    test: spec/mailers/request_mailer_spec.rb:618
  overdue_alert(info_request, user)
    test: spec/mailers/request_mailer_spec.rb:792
  very_overdue_alert(info_request, user)
    test: spec/mailers/request_mailer_spec.rb:921
  new_response_reminder_alert(info_request, incoming_message)
    test: spec/mailers/request_mailer_spec.rb:672/691
  old_unclassified_updated(info_request)
    test: spec/mailers/request_mailer_spec.rb:545
  not_clarified_alert(info_request, incoming_message)
    test: spec/mailers/request_mailer_spec.rb:995
  comment_on_alert(info_request, comment)
    test: spec/mailers/request_mailer_spec.rb:1019
  comment_on_alert_plural(info_request, count, earliest_unalerted_comment)
    test: spec/mailers/request_mailer_spec.rb:1044
app/mailers/survey_mailer.rb
  survey_alert(info_request)
    test: spec/mailers/survey_mailer_spec.rb:29/45
app/mailers/track_mailer.rb
  event_digest(user, email_about_things)
    test: spec/mailers/track_mailer_spec.rb:193/220/223
app/mailers/user_mailer.rb
  confirm_login(user, reasons, url)
    No new functionality to test
  already_registered(user, reasons, url)
    No new functionality to test
  changeemail_confirm(user, new_email, url)
    No new functionality to test
  changeemail_already_used(old_email, new_email)
    No new functionality to test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alert emails sent to the user always use the site's default language
1 participant