]> source.dussan.org Git - redmine.git/commitdiff
Fixed: The error flash message on session expiration is not in the language of the...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 13 Sep 2014 10:35:46 +0000 (10:35 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 13 Sep 2014 10:35:46 +0000 (10:35 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13391 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/application_controller.rb
test/functional/sessions_test.rb

index 10e0ecbb20f19e87267d6da9b8f3905c9b4585b7..e70f1602cef0e20764a1ca6d3fdaf1449987998b 100644 (file)
@@ -61,6 +61,7 @@ class ApplicationController < ActionController::Base
   def session_expiration
     if session[:user_id]
       if session_expired? && !try_to_autologin
+        set_localization(User.active.find_by_id(session[:user_id]))
         reset_session
         flash[:error] = l(:error_session_expired)
         redirect_to signin_url
@@ -197,10 +198,10 @@ class ApplicationController < ActionController::Base
     end
   end
 
-  def set_localization
+  def set_localization(user=User.current)
     lang = nil
-    if User.current.logged?
-      lang = find_language(User.current.language)
+    if user && user.logged?
+      lang = find_language(user.language)
     end
     if lang.nil? && !Setting.force_default_language_for_anonymous? && request.env['HTTP_ACCEPT_LANGUAGE']
       accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first
index a9283e03b40cfbc7938d6d3d128a174ef9347ca5..3aa9e70ad74977797ac0d4619bb6220283ff380d 100644 (file)
@@ -32,6 +32,7 @@ class SessionStartTest < ActionController::TestCase
 end
 
 class SessionsTest < ActionController::TestCase
+  include Redmine::I18n
   tests WelcomeController
 
   fixtures :users
@@ -108,6 +109,20 @@ class SessionsTest < ActionController::TestCase
     end
   end
 
+  def test_expired_user_session_should_set_locale
+    set_language_if_valid 'it'
+    user = User.find(2)
+    user.language = 'fr'
+    user.save!
+
+    with_settings :session_timeout => '60' do
+      get :index, {}, {:user_id => user.id, :atime => 4.hours.ago.utc.to_i}
+      assert_redirected_to '/login'
+      assert_include "Veuillez vous reconnecter", flash[:error]
+      assert_equal :fr, current_language
+    end
+  end
+
   def test_anonymous_session_should_not_be_reset
     with_settings :session_lifetime => '720', :session_timeout => '60' do
       get :index