locale control is in!

Oleg committed Jun 24, 2011
commit 51345cabd833b8b6a1ab718e995e917dcc9bc84d
Showing 3 changed files with 26 additions and 0 deletions
app/controllers/cms_admin/base_controller.rb +1 -0
@@ @@ -26,6 +26,7 @@ protected
flash[:error] = 'Site not found'
return redirect_to(new_cms_admin_site_path)
end
+ I18n.locale = @site.locale
end
def load_fixtures
app/controllers/cms_content_controller.rb +1 -0
@@ @@ -37,6 +37,7 @@ protected
if @cms_site
params[:cms_path].to_s.gsub!(/^#{@cms_site.path}/, '').gsub!(/^\//, '')
+ I18n.locale = @cms_site.locale
else
render :text => 'Site Not Found', :status => 404
end
test/integration/sites_test.rb +24 -0
@@ @@ -57,4 +57,28 @@ class SitesTest < ActionDispatch::IntegrationTest
end
end
+ def test_get_public_with_locale
+ get '/'
+ assert_response :success
+ assert assigns(:cms_site)
+ assert_equal :en, I18n.locale
+
+ cms_sites(:default).update_attribute(:locale, 'fr')
+ get '/'
+ assert_response :success
+ assert assigns(:cms_site)
+ assert_equal :fr, I18n.locale
+ end
+
+ def test_get_admin_with_locale
+ http_auth :get, cms_admin_site_pages_path(cms_sites(:default))
+ assert_response :success
+ assert_equal :en, I18n.locale
+
+ cms_sites(:default).update_attribute(:locale, 'fr')
+ http_auth :get, cms_admin_site_pages_path(cms_sites(:default))
+ assert_response :success
+ assert_equal :fr, I18n.locale
+ end
+
end
\ No newline at end of file