]> source.dussan.org Git - redmine.git/commitdiff
Localisation not set correctly on authenticity token errors (#18499).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 29 Nov 2014 15:16:59 +0000 (15:16 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 29 Nov 2014 15:16:59 +0000 (15:16 +0000)
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
test/integration/application_test.rb

index 7fedd44ff8789e529648e98a71fa9cac52c549c9..fbdb1d301408a74d6705173cd66a4b170e6391c3 100644 (file)
@@ -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
index e70277a2ef4914507e45a70e188ced505f1ae38c..e40dda8ea6bf68eea07bf95ed58054d65aa1734c 100644 (file)
@@ -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