Skip to content

Commit fde8d77

Browse files
committed
AO3-6814 Enable translated emails for archivist__added_to_collection_notification
1 parent 51092cd commit fde8d77

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

app/models/collection_item.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,13 @@ def notify_archivist_added
106106
item.users.each do |email_recipient|
107107
next if email_recipient.preference.collection_emails_off
108108

109-
UserMailer.archivist_added_to_collection_notification(
110-
email_recipient.id,
111-
item.id,
112-
collection.id
113-
).deliver_later
109+
I18n.with_locale(email_recipient.preference.locale.iso) do
110+
UserMailer.archivist_added_to_collection_notification(
111+
email_recipient.id,
112+
item.id,
113+
collection.id
114+
).deliver_later
115+
end
114116
end
115117
end
116118

features/collections/collection_notification.feature

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,20 @@ Feature: Collectible items email
6363
And I fill in "bookmark_collection_names" with "dont_bookmark_me_bro"
6464
And I press "Create"
6565
Then 1 email should be delivered
66+
67+
Scenario: Archivist adds work to collection
68+
Given I am logged in as "regular_user"
69+
And I post the work "Collection Work"
70+
And a locale with translated emails
71+
And the user "regular_user" enables translated emails
72+
And I have an archivist "archivist"
73+
When all emails have been delivered
74+
And I am logged in as "archivist"
75+
And I create the collection "Open Doors Collection" with name "open_doors_collection"
76+
And I view the work "Collection Work"
77+
And I follow "Add to Collections"
78+
And I fill in "collection_names" with "open_doors_collection"
79+
And I press "Add"
80+
Then I should see "Added to collection(s): Open Doors Collection"
81+
And 1 email should be delivered
82+
And the email to "regular_user" should be translated

test/mailers/previews/user_mailer_preview.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ def admin_deleted_work_notification
6060
UserMailer.admin_deleted_work_notification(user, work)
6161
end
6262

63+
def archivist_added_to_collection_notification
64+
work = create(:work)
65+
collection = create(:collection)
66+
user = create(:user, :for_mailer_preview)
67+
UserMailer.archivist_added_to_collection_notification(user.id, work.id, collection.id)
68+
end
69+
6370
private
6471

6572
def creatorship_notification_data(creation_type)

0 commit comments

Comments
 (0)