mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 10:57:04 +08:00
Add username template variables to Welcome User email template (#20352)
* Add username and name_or_username variables to SystemMessage defaults * Allow username and name variables on welcome_user email template overrides * Satisfy linting * Add test
This commit is contained in:
parent
9519747a01
commit
6fa9a8990d
|
@ -35,6 +35,7 @@ class TranslationOverride < ActiveRecord::Base
|
|||
optional_cat
|
||||
optional_tags
|
||||
],
|
||||
%w[system_messages.welcome_user] => %w[username name name_or_username],
|
||||
}
|
||||
|
||||
include HasSanitizableFields
|
||||
|
|
|
@ -88,6 +88,8 @@ class SystemMessage
|
|||
{
|
||||
site_name: SiteSetting.title,
|
||||
username: @recipient.username,
|
||||
name: @recipient.name,
|
||||
name_or_username: @recipient.name.presence || @recipient.username,
|
||||
user_preferences_url: "#{@recipient.full_url}/preferences",
|
||||
new_user_tips:
|
||||
I18n.with_locale(@recipient.effective_locale) do
|
||||
|
|
|
@ -84,6 +84,19 @@ RSpec.describe TranslationOverride do
|
|||
end
|
||||
end
|
||||
|
||||
describe "with valid custom interpolation keys" do
|
||||
it "works" do
|
||||
translation_override =
|
||||
TranslationOverride.upsert!(
|
||||
I18n.locale,
|
||||
"system_messages.welcome_user.text_body_template",
|
||||
"Hello %{name} %{username} %{name_or_username} and welcome to %{site_name}!",
|
||||
)
|
||||
|
||||
expect(translation_override.errors).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
describe "pluralized keys" do
|
||||
describe "valid keys" do
|
||||
it "converts zero to other" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user