From 809c3aaa305673c55daca2fa0b34dcfc8dfade8e Mon Sep 17 00:00:00 2001 From: indes-castille <156284337+indes-castille@users.noreply.github.com> Date: Sat, 11 Jan 2025 04:49:42 +1100 Subject: [PATCH] AO3-6814 Enable translated emails for archivist__added_to_collection_notification --- app/models/collection_item.rb | 12 +++++++----- .../collections/collection_notification.feature | 17 +++++++++++++++++ test/mailers/previews/user_mailer_preview.rb | 7 +++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/app/models/collection_item.rb b/app/models/collection_item.rb index 9db2757fc57..e3bdfa4ff49 100644 --- a/app/models/collection_item.rb +++ b/app/models/collection_item.rb @@ -106,11 +106,13 @@ def notify_archivist_added item.users.each do |email_recipient| next if email_recipient.preference.collection_emails_off - UserMailer.archivist_added_to_collection_notification( - email_recipient.id, - item.id, - collection.id - ).deliver_later + I18n.with_locale(email_recipient.preference.locale.iso) do + UserMailer.archivist_added_to_collection_notification( + email_recipient.id, + item.id, + collection.id + ).deliver_later + end end end diff --git a/features/collections/collection_notification.feature b/features/collections/collection_notification.feature index 49a52f4861b..575b1f8b77f 100644 --- a/features/collections/collection_notification.feature +++ b/features/collections/collection_notification.feature @@ -63,3 +63,20 @@ Feature: Collectible items email And I fill in "bookmark_collection_names" with "dont_bookmark_me_bro" And I press "Create" Then 1 email should be delivered + + Scenario: Archivist adds work to collection + Given I am logged in as "regular_user" + And I post the work "Collection Work" + And a locale with translated emails + And the user "regular_user" enables translated emails + And I have an archivist "archivist" + When all emails have been delivered + And I am logged in as "archivist" + And I create the collection "Open Doors Collection" with name "open_doors_collection" + And I view the work "Collection Work" + And I follow "Add to Collections" + And I fill in "collection_names" with "open_doors_collection" + And I press "Add" + Then I should see "Added to collection(s): Open Doors Collection" + And 1 email should be delivered + And the email to "regular_user" should be translated \ No newline at end of file diff --git a/test/mailers/previews/user_mailer_preview.rb b/test/mailers/previews/user_mailer_preview.rb index 7aa217d946d..ab22311b140 100644 --- a/test/mailers/previews/user_mailer_preview.rb +++ b/test/mailers/previews/user_mailer_preview.rb @@ -54,6 +54,13 @@ def change_email UserMailer.change_email(user.id, old_email, new_email) end + def archivist_added_to_collection_notification + work = create(:work) + collection = create(:collection) + user = create(:user, :for_mailer_preview) + UserMailer.archivist_added_to_collection_notification(user.id, work.id, collection.id) + end + private def creatorship_notification_data(creation_type)