diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-12-12 06:05:35 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-12-12 06:05:35 +0000 |
commit | cabfece11ba402c22b443baefe7d142700a4d80e (patch) | |
tree | 4af94765c6dffef77da1c71734335635bc211b6b | |
parent | 24be0551ccd77c7facf0278825973d604942d88a (diff) | |
download | redmine-cabfece11ba402c22b443baefe7d142700a4d80e.tar.gz redmine-cabfece11ba402c22b443baefe7d142700a4d80e.zip |
Use browser language as default when registering.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10988 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/controllers/account_controller.rb | 2 | ||||
-rw-r--r-- | test/functional/account_controller_test.rb | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 9eaf5f6d3..c8d27d33f 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -95,7 +95,7 @@ class AccountController < ApplicationController redirect_to(home_url) && return unless Setting.self_registration? || session[:auth_source_registration] if request.get? session[:auth_source_registration] = nil - @user = User.new(:language => Setting.default_language) + @user = User.new(:language => current_language.to_s) else user_params = params[:user] || {} @user = User.new diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 08960b451..0f876963f 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -99,6 +99,19 @@ class AccountControllerTest < ActionController::TestCase 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 with_settings :self_registration => '0' do get :register |