diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-12-05 16:57:02 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-12-05 18:54:20 +0000 |
commit | 3ad5277ed2c9f98508a7208848e125d274c86a3b (patch) | |
tree | 87f8fdb3cc62b26c4766b8ed46c46bd23b3950e8 | |
parent | d35b7fec9ad723496c95791ae314964f4d3360dd (diff) |
Search for bodies using the underscore version of the locale.
-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 |