Skip to content

Commit

Permalink
AO3-6814 Enable translated emails for archivist__added_to_collection_…
Browse files Browse the repository at this point in the history
…notification
  • Loading branch information
indesotw committed Jan 10, 2025
1 parent 51092cd commit fde8d77
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/models/collection_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 17 additions & 0 deletions features/collections/collection_notification.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions test/mailers/previews/user_mailer_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ def admin_deleted_work_notification
UserMailer.admin_deleted_work_notification(user, work)
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)
Expand Down

0 comments on commit fde8d77

Please sign in to comment.