diff options
author | Louise Crow <louise.crow@gmail.com> | 2014-10-14 13:29:49 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2014-10-28 08:40:21 +0000 |
commit | 5bb459de4ba327e54c97c75bf4ea660cc909efd4 (patch) | |
tree | e7d2e748adb6556700169782e175029a36fca755 /lib | |
parent | 074fcf036ad91ae57f82adf5c93d143e3fadabb3 (diff) |
Allow resetting of the locale pattern on the locale routing filter.
An order-dependent error in locale integration tests
(https://travis-ci.org/mysociety/alaveteli/jobs/37914013) showed that
the routing filter pattern was not being updated from it's initial value
when a new set of available locales was passed to AlaveteliLocalization.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/alaveteli_localization.rb | 1 | ||||
-rw-r--r-- | lib/routing_filters.rb | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/alaveteli_localization.rb b/lib/alaveteli_localization.rb index 6daab124a..2b6978c92 100644 --- a/lib/alaveteli_localization.rb +++ b/lib/alaveteli_localization.rb @@ -7,6 +7,7 @@ class AlaveteliLocalization I18n.locale = default_locale I18n.available_locales = available_locales.map { |locale_name| locale_name.to_sym } I18n.default_locale = default_locale + RoutingFilter::Conditionallyprependlocale.locales = available_locales end def set_default_text_domain(name, path) diff --git a/lib/routing_filters.rb b/lib/routing_filters.rb index a9a62b8db..5b5da6870 100644 --- a/lib/routing_filters.rb +++ b/lib/routing_filters.rb @@ -22,5 +22,13 @@ module RoutingFilter prepend_segment!(result, locale) if prepend_locale?(locale) end end + + # Reset the locale pattern when the locales are set. + class << self + def locales=(locales) + @@locales_pattern = nil + @@locales = locales.map(&:to_sym) + end + end end end |