FIX: Add missing email template for `user_watching_category_or_tag` (#19653)

Adds a spec to hopefully prevent this in the future.

Follow-up to aa3a9b6fea
This commit is contained in:
Gerhard Schlager 2022-12-29 15:36:53 +01:00 committed by GitHub
parent 2644a4d303
commit 7e33cb3665
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 0 deletions

View File

@ -3791,6 +3791,18 @@ en:
%{respond_instructions}
user_watching_category_or_tag:
title: "User Watching Category or Tag"
subject_template: "[%{email_prefix}] %{topic_title}"
text_body_template: |
%{header_instructions}
%{message}
%{context}
%{respond_instructions}
user_watching_first_post:
title: "User Watching First Post"
subject_template: "[%{email_prefix}] %{topic_title}"

View File

@ -197,6 +197,15 @@ RSpec.describe NotificationEmailer do
include_examples "enqueue_public"
end
context 'with user_watching_category_or_tag' do
let(:no_delay) { no_delay }
let(:type) { :user_posted }
let(:delay) { SiteSetting.email_time_window_mins.minutes }
let!(:notification) { create_notification(:watching_category_or_tag) }
include_examples "enqueue_public"
end
context 'with user_private_message' do
let(:no_delay) { no_delay }
let(:type) { :user_private_message }
@ -251,4 +260,34 @@ RSpec.describe NotificationEmailer do
include_examples "enqueue_public"
end
end
it "has translations for each sendable notification type" do
notification = create_notification(:mentioned)
email_user = NotificationEmailer::EmailUser.new(notification, no_delay: true)
subkeys = ["title", "subject_template", "text_body_template"]
# some notification types need special handling
replace_keys = {
"post_approved" => ["post_approved"],
"private_message" => ["user_posted"],
"invited_to_private_message" => [
"user_invited_to_private_message_pm",
"user_invited_to_private_message_pm_group",
"user_invited_to_private_message_pm_staged"
]
}
Notification.types.keys.each do |notification_type|
if email_user.respond_to?(notification_type)
type_keys = replace_keys[notification_type.to_s] || ["user_#{notification_type}"]
type_keys.each do |type_key|
subkeys.each do |subkey|
key = "user_notifications.#{type_key}.#{subkey}"
expect(I18n.exists?(key)).to eq(true), "missing translation: #{key}"
end
end
end
end
end
end