fixed setting locale in admin pages
Olli Huotari
committed Feb 03, 2012
commit c04564bd92254044d5a54c95515cdd3c82abb08a
Showing 2
changed files with
16 additions
and 1 deletions
app/controllers/cms_admin/base_controller.rb
+6
-1
| @@ | @@ -7,6 +7,7 @@ class CmsAdmin::BaseController < ApplicationController |
| before_filter :authenticate, | |
| :load_admin_site, | |
| + | :set_locale, |
| :load_fixtures, | |
| :except => :jump | |
| @@ | @@ -27,7 +28,11 @@ protected |
| flash[:error] = I18n.t('cms.base.site_not_found') | |
| return redirect_to(new_cms_admin_site_path) | |
| end | |
| - | I18n.locale = ComfortableMexicanSofa.config.admin_locale || @site.locale |
| + | end |
| + | |
| + | def set_locale |
| + | I18n.locale = ComfortableMexicanSofa.config.admin_locale || (@site && @site.locale) |
| + | true |
| end | |
| def load_fixtures | |
test/integration/sites_test.rb
+10
-0
| @@ | @@ -83,10 +83,20 @@ class SitesTest < ActionDispatch::IntegrationTest |
| def test_get_admin_with_forced_locale | |
| ComfortableMexicanSofa.config.admin_locale = :en | |
| + | |
| cms_sites(:default).update_attribute(:locale, 'fr') | |
| http_auth :get, cms_admin_site_pages_path(cms_sites(:default)) | |
| assert_response :success | |
| assert_equal :en, I18n.locale | |
| + | |
| + | I18n.default_locale = :fr |
| + | I18n.locale = :fr |
| + | http_auth :get, cms_admin_sites_path() |
| + | assert_response :success |
| + | assert_equal :en, I18n.locale |
| + | |
| + | I18n.default_locale = :en |
| + | |
| end | |
| end | |
| \ No newline at end of file | |