Use browser language as default when registering.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10988 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-12-12 06:05:35 +00:00
parent 24be0551cc
commit cabfece11b
2 changed files with 14 additions and 1 deletions

View File

@ -95,7 +95,7 @@ class AccountController < ApplicationController
redirect_to(home_url) && return unless Setting.self_registration? || session[:auth_source_registration] redirect_to(home_url) && return unless Setting.self_registration? || session[:auth_source_registration]
if request.get? if request.get?
session[:auth_source_registration] = nil session[:auth_source_registration] = nil
@user = User.new(:language => Setting.default_language) @user = User.new(:language => current_language.to_s)
else else
user_params = params[:user] || {} user_params = params[:user] || {}
@user = User.new @user = User.new

View File

@ -99,6 +99,19 @@ class AccountControllerTest < ActionController::TestCase
end end
end end
def test_get_register_should_detect_user_language
with_settings :self_registration => '3' do
@request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
get :register
assert_response :success
assert_not_nil assigns(:user)
assert_equal 'fr', assigns(:user).language
assert_select 'select[name=?]', 'user[language]' do
assert_select 'option[value=fr][selected=selected]'
end
end
end
def test_get_register_with_registration_off_should_redirect def test_get_register_with_registration_off_should_redirect
with_settings :self_registration => '0' do with_settings :self_registration => '0' do
get :register get :register