aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/public_body_controller_spec.rb
diff options
context:
space:
mode:
authorMark Longair <mhl@pobox.com>2013-08-29 10:24:02 +0100
committerMark Longair <mhl@pobox.com>2013-09-10 14:59:58 +0100
commit3fb80a12652792df9da06c22b4bb944ab80bf376 (patch)
tree7d513312a0df678fae06fff3ab88d85c161bec90 /spec/controllers/public_body_controller_spec.rb
parent17199cf44fd4ad8dcf700a13126607c42bb3be34 (diff)
Make falling back to default locale in public body listings optional
As the code stood, the list method in PublicBodyController would only return results that had translations of the public body in the default locale. This has a variety of problems if you're viewing pages in the non-default locale - for example, the "first letter" links wouldn't bring up the public bodies that began with that letter in the current locale, only those that began with it in the default locale. Ideally, every public body would be translated into every available locale for the site, but there are cases where deployers wish to have public body listings also include those from the default locale, in case there are untralsated public bodies: https://groups.google.com/d/msg/alaveteli-dev/zUY_USaAMAM/M7KTQ9RC5YUJ This commit makes the default behaviour to look for public body listings only in the current locale, but if the new configuration option PUBLIC_BODY_LIST_FALLBACK_TO_DEFAULT_LOCALE is set, then public body listings will be looked for in both the current locale and the default locale. Fixes #1000
Diffstat (limited to 'spec/controllers/public_body_controller_spec.rb')
-rw-r--r--spec/controllers/public_body_controller_spec.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index 4e1841164..2b921b488 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -78,7 +78,8 @@ describe PublicBodyController, "when listing bodies" do
response.should be_success
end
- it "should list all bodies from default locale, even when there are no translations for selected locale" do
+ it "if fallback is requested, should list all bodies from default locale, even when there are no translations for selected locale" do
+ AlaveteliConfiguration.stub!(:public_body_list_fallback_to_default_locale).and_return(true)
I18n.with_locale(:en) do
@english_only = PublicBody.new(:name => 'English only',
:short_name => 'EO',
@@ -96,6 +97,12 @@ describe PublicBodyController, "when listing bodies" do
response.should contain('El Department for Humpadinking')
end
+ it 'should not show the internal admin authority' do
+ PublicBody.internal_admin_body
+ get :list, {:locale => 'en'}
+ response.should_not contain('Internal admin authority')
+ end
+
it 'should show public body names in the selected locale language if present for a locale with underscores' do
AlaveteliLocalization.set_locales('he_IL en', 'en')
get :list, {:locale => 'he_IL'}