summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/account_controller.rb2
-rw-r--r--test/functional/account_controller_test.rb13
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