mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
validate user locale
This commit is contained in:
parent
b2b7342d53
commit
2d8b10d139
2 changed files with 15 additions and 1 deletions
|
@ -188,7 +188,7 @@ class UserNotifications < ActionMailer::Base
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def user_locale(user)
|
def user_locale(user)
|
||||||
user.respond_to?(:locale) ? user.locale : nil
|
(user.locale.present? && I18n.available_locales.include?(user.locale.to_sym)) ? user.locale : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def email_post_markdown(post)
|
def email_post_markdown(post)
|
||||||
|
|
|
@ -429,5 +429,19 @@ describe UserNotifications do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "user locale is not a valid locale" do
|
||||||
|
%w(signup signup_after_approval authorize_email forgot_password admin_login account_created).each do |mail_type|
|
||||||
|
include_examples "notification derived from template" do
|
||||||
|
SiteSetting.default_locale = "en"
|
||||||
|
let(:locale) { "invalid" }
|
||||||
|
let(:mail_type) { mail_type }
|
||||||
|
it "sets the locale" do
|
||||||
|
expects_build_with(has_entry(:locale, nil))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue