A11Y: sets the html lang to user's locale when possible (#12007)

This commit is contained in:
Joffrey JAFFEUX
2021-02-10 16:12:09 +01:00
committed by GitHub
parent d3f03bfb0e
commit ad7ca46231
2 changed files with 20 additions and 1 deletions

View File

@ -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