mirror of
https://github.com/discourse/discourse.git
synced 2025-09-10 05:01:43 +08:00
Merge pull request #4006 from scossar/set-locale-from-header
Feature: (WIP) Set locale from Accept-Language header
This commit is contained in:
commit
1135d2094a
8 changed files with 146 additions and 18 deletions
|
@ -479,6 +479,15 @@ describe UsersController do
|
|||
email: @user.email
|
||||
end
|
||||
|
||||
context 'when creating a user' do
|
||||
it 'sets the user locale to I18n.locale' do
|
||||
SiteSetting.stubs(:default_locale).returns('en')
|
||||
I18n.stubs(:locale).returns(:fr)
|
||||
post_user
|
||||
expect(User.find_by(username: @user.username).locale).to eq('fr')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when creating a non active user (unconfirmed email)' do
|
||||
|
||||
it 'returns a 500 when local logins are disabled' do
|
||||
|
@ -1181,6 +1190,19 @@ describe UsersController do
|
|||
|
||||
end
|
||||
|
||||
context 'a locale is chosen that differs from I18n.locale' do
|
||||
it "updates the user's locale" do
|
||||
I18n.stubs(:locale).returns('fr')
|
||||
|
||||
put :update,
|
||||
username: user.username,
|
||||
locale: :fa_IR
|
||||
|
||||
expect(User.find_by(username: user.username).locale).to eq('fa_IR')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "with user fields" do
|
||||
context "an editable field" do
|
||||
let!(:user_field) { Fabricate(:user_field) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue