aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2015-04-29 16:42:26 +0100
committerGareth Rees <gareth@mysociety.org>2015-04-29 16:42:26 +0100
commit196cce975887aca513b0fca6e90f8024aff981e5 (patch)
treeb9a22d6e561f9da339d8e29dd8d17d8e7ed2bea5 /spec/models
parent4b6cc7d1aa1e7d095e94aad7522385d66314879b (diff)
Rescue from Holidays::UnknownRegionErrorhotfix/0.21.0.24
If you run an Alaveteli in a region where we can’t show holiday suggestions the holiday import page breaks. This commit rescues from an unavailable region so that we display a friendly error message.
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/holiday_import_spec.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/spec/models/holiday_import_spec.rb b/spec/models/holiday_import_spec.rb
index 59448104e..7ec5c04d5 100644
--- a/spec/models/holiday_import_spec.rb
+++ b/spec/models/holiday_import_spec.rb
@@ -102,6 +102,13 @@ describe HolidayImport do
holiday.day.should == Date.new(2014, 1, 1)
end
+ it 'returns an empty array for an unknown country code' do
+ AlaveteliConfiguration.stub(:iso_country_code).and_return('UNKNOWN_COUNTRY_CODE')
+ @holiday_import = HolidayImport.new(:source => 'suggestions')
+ @holiday_import.populate
+ expect(@holiday_import.holidays).to be_empty
+ end
+
it 'should return a flag that it has been populated' do
holidays = [ { :date => Date.new(2014, 1, 1),
:name => "New Year's Day",