diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2012-06-14 13:47:47 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2012-06-14 13:47:47 +0100 |
commit | b30554dc4fcdeeb42d827ead474b1e135bc877e8 (patch) | |
tree | 0d174d7135a102b8b01064b8ebcb20f70a17658a /spec/controllers/general_controller_spec.rb | |
parent | 118bc669365a38d60f696802e1f5d678393ed2f3 (diff) |
Ensure we generate URLs containing the current locale, even if the locale contains an underscore.
Includes a bonus test to ensure that locales with unknown territories fall back to known languages.
Diffstat (limited to 'spec/controllers/general_controller_spec.rb')
-rw-r--r-- | spec/controllers/general_controller_spec.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index 19b96eb23..df2c139bd 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -77,7 +77,7 @@ describe GeneralController, "when searching" do end describe "when using different locale settings" do - home_link_regex = /href=".*\/en"/ + home_link_regex = /href=".*\/en\// it "should generate URLs with a locale prepended when there's more than one locale set" do get :frontpage response.should have_text(home_link_regex) @@ -87,7 +87,24 @@ describe GeneralController, "when searching" do I18n.default_locale = :es get :frontpage response.should have_text(/XOXO/) + I18n.default_locale = :en end + + it "should generate URLs that include the locale when using one that includes an underscore" do + I18n.default_locale = :"en_GB" + get :frontpage + response.should have_text(/href="\/en_GB\//) + I18n.default_locale = :en + end + + it "should fall back to the language if the territory is unknown" do + I18n.default_locale = :"en_US" + get :frontpage + response.should have_text(/href="\/en\//) + response.should_not have_text(/href="\/en_US\//) + I18n.default_locale = :en + end + it "should generate URLs without a locale prepended when there's only one locale set" do old_fgt_available_locales = FastGettext.default_available_locales old_i18n_available_locales = I18n.available_locales |