adding admin_locale setting
Oleg
committed Jun 25, 2011
commit 1be469e5b16b8b80738c90ff23c999124ebe8489
Showing 4
changed files with
15 additions
and 3 deletions
app/controllers/cms_admin/base_controller.rb
+2
-2
| @@ | @@ -23,11 +23,11 @@ protected |
| def load_admin_site | |
| unless (@site = Cms::Site.find_by_id(params[:site_id]) || Cms::Site.first) | |
| - | I18n.locale = I18n.default_locale |
| + | I18n.locale = ComfortableMexicanSofa.config.admin_locale || I18n.default_locale |
| flash[:error] = I18n.t('cms.base.site_not_found') | |
| return redirect_to(new_cms_admin_site_path) | |
| end | |
| - | I18n.locale = @site.locale |
| + | I18n.locale = ComfortableMexicanSofa.config.admin_locale || @site.locale |
| end | |
| def load_fixtures | |
app/controllers/cms_admin/sites_controller.rb
+1
-1
| @@ | @@ -52,7 +52,7 @@ protected |
| def load_site | |
| @site = Cms::Site.find(params[:id]) | |
| - | I18n.locale = @site.locale |
| + | I18n.locale = ComfortableMexicanSofa.config.admin_locale || @site.locale |
| rescue ActiveRecord::RecordNotFound | |
| flash[:error] = I18n.t('cms.sites.not_found') | |
| redirect_to :action => :index | |
test/integration/sites_test.rb
+8
-0
| @@ | @@ -81,4 +81,12 @@ class SitesTest < ActionDispatch::IntegrationTest |
| assert_equal :fr, I18n.locale | |
| end | |
| + | 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 |
| + | end |
| + | |
| end | |
| \ No newline at end of file | |
test/test_helper.rb
+4
-0
| @@ | @@ -1,3 +1,5 @@ |
| + | # encoding: utf-8 |
| + | |
| ENV['RAILS_ENV'] = 'test' | |
| require File.expand_path('../../config/environment', __FILE__) | |
| require 'rails/test_help' | |
| @@ | @@ -22,6 +24,8 @@ class ActiveSupport::TestCase |
| config.enable_fixtures = false | |
| config.fixtures_path = File.expand_path('db/cms_fixtures', Rails.root) | |
| config.revisions_limit = 25 | |
| + | config.locales = { :en => 'English', :es => 'Español' } |
| + | config.admin_locale = nil |
| end | |
| ComfortableMexicanSofa::HttpAuth.username = 'username' | |
| ComfortableMexicanSofa::HttpAuth.password = 'password' | |