diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2011-07-15 10:44:38 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2011-07-15 10:44:38 +0100 |
commit | 183b5be4f8e2e7396a32c6d15f6fb5c085ba0889 (patch) | |
tree | 8ab399c250799a8c337aa596e8aeebfd08d9a95f /spec/controllers/general_controller_spec.rb | |
parent | 62b006d959caf95870f9215e56fb3594c585a259 (diff) |
Only prepend locales to paths when there's more than one locale to choose from.
Replaces core "locale" filter with customised one. Fixes #82
Diffstat (limited to 'spec/controllers/general_controller_spec.rb')
-rw-r--r-- | spec/controllers/general_controller_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index 6a48f142a..7807a5541 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -22,6 +22,29 @@ describe GeneralController, "when searching" do response.should redirect_to(:action => 'search', :combined => "mouse") # URL /search/:query end + describe "when using different locale settings" do + home_link_regex = /href=".*\/en"/ + it "should generate URLs with a locale prepended when there's more than one locale set" do + ActionController::Routing::Routes.add_filters(['conditionallyprependlocale']) + get :frontpage + response.should have_text(home_link_regex) + end + + it "should generate URLs without a locale prepended when there's only one locale set" do + ActionController::Routing::Routes.add_filters(['conditionallyprependlocale']) + old_available_locales = FastGettext.default_available_locales + available_locales = ['en'] + FastGettext.default_available_locales = available_locales + I18n.available_locales = available_locales + + get :frontpage + response.should_not have_text(home_link_regex) + + FastGettext.default_available_locales = old_available_locales + I18n.available_locales = old_available_locales + end + end + describe 'when using xapian search' do # rebuild xapian index after fixtures loaded |