set locale for anonymous from header

set locale on signup

update spec

add locale option
This commit is contained in:
scossar
2016-02-06 11:49:39 -08:00
parent f887363e83
commit 0a396583ed
8 changed files with 146 additions and 18 deletions

View File

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