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

AO3-6814 Respect locale preferences for archivist_added_to_collection_notification email #5023

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 8 additions & 1 deletion test/mailers/previews/user_mailer_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ def invite_increase_notification
total = params[:total] || 1
UserMailer.invite_increase_notification(user.id, total.to_i)
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
Loading