From 6f3ab71f3f4b62af5f241cb9e7a967903d68aeaf Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 29 Nov 2014 15:16:59 +0000 Subject: Localisation not set correctly on authenticity token errors (#18499). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Felix Schäfer. git-svn-id: http://svn.redmine.org/redmine/trunk@13670 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/application_controller.rb | 1 + test/integration/application_test.rb | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7fedd44ff..fbdb1d301 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -45,6 +45,7 @@ class ApplicationController < ActionController::Base super cookies.delete(autologin_cookie_name) self.logged_user = nil + set_localization render_error :status => 422, :message => "Invalid form authenticity token." end end diff --git a/test/integration/application_test.rb b/test/integration/application_test.rb index e70277a2e..e40dda8ea 100644 --- a/test/integration/application_test.rb +++ b/test/integration/application_test.rb @@ -76,4 +76,15 @@ class ApplicationTest < ActionDispatch::IntegrationTest ensure ActionController::Base.allow_forgery_protection = false end + + def test_localization_should_be_set_correctly_on_invalid_token + ActionController::Base.allow_forgery_protection = true + Setting.default_language = 'en' + post 'issues', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3' + assert_response 422 + assert_equal :fr, current_language + assert_select "html[lang=?]", "fr" + ensure + ActionController::Base.allow_forgery_protection = false + end end -- cgit v1.2.3