mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
A11Y: sets the html lang to user's locale when possible (#12007)
This commit is contained in:
@ -514,4 +514,23 @@ describe ApplicationHelper do
|
||||
expect(helper.dark_color_scheme?).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'html_lang' do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
|
||||
before do
|
||||
I18n.locale = :de
|
||||
SiteSetting.default_locale = :fr
|
||||
end
|
||||
|
||||
it 'returns default locale if no request' do
|
||||
helper.request = nil
|
||||
expect(helper.html_lang).to eq(SiteSetting.default_locale)
|
||||
end
|
||||
|
||||
it 'returns current user locale if request' do
|
||||
helper.request.env[Auth::DefaultCurrentUserProvider::CURRENT_USER_KEY] = user
|
||||
expect(helper.html_lang).to eq(I18n.locale.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user