diff options
-rw-r--r-- | app/models/public_body.rb | 3 | ||||
-rw-r--r-- | spec/models/public_body_spec.rb | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 8e474c797..c007afb6e 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -727,7 +727,8 @@ class PublicBody < ActiveRecord::Base # either from config, or based on a (slow!) query if not set body_short_names = AlaveteliConfiguration::frontpage_publicbody_examples.split(/\s*;\s*/) locale_condition = 'public_body_translations.locale = ?' - conditions = [locale_condition, locale] + underscore_locale = locale.gsub '-', '_' + conditions = [locale_condition, underscore_locale] bodies = [] I18n.with_locale(locale) do if body_short_names.empty? diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index 23842ccff..0c29503a3 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -604,3 +604,12 @@ describe PublicBody, "when calculating statistics" do end end + +describe PublicBody, 'when asked for popular bodies' do + + it 'should return bodies correctly when passed the hyphenated version of the locale' do + AlaveteliConfiguration.stub!(:frontpage_publicbody_examples).and_return('') + PublicBody.popular_bodies('he-IL').should == [public_bodies(:humpadink_public_body)] + end + +end |