diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2011-08-08 13:02:03 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2011-08-08 14:57:01 +0100 |
commit | a3c00d25d1bf6dc9ef554a44809e732a96ec1533 (patch) | |
tree | 0b9f7dd0ad5cb48c458487e3fd28960146830a95 /spec/controllers/general_controller_spec.rb | |
parent | 99548c87d201871a150e395c334e07149651996a (diff) |
Ensure we use sensible fallbacks for setting the default / initial locale for a user. (Partially) fixes #114
Diffstat (limited to 'spec/controllers/general_controller_spec.rb')
-rw-r--r-- | spec/controllers/general_controller_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index 619635eea..63ad6873c 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -17,6 +17,27 @@ describe GeneralController, "when searching" do response.should be_success end + it "should render the front page with default language" do + get :frontpage + response.should have_tag('html[lang="en"]') + end + + it "should render the front page with default language" do + old_default_locale = I18n.default_locale + I18n.default_locale = "es" + get :frontpage + response.should have_tag('html[lang="es"]') + I18n.default_locale = old_default_locale + end + + it "should render the front page with browser-selected language" do + accept_language = "es-ES,en-GB,en-US;q=0.8,en;q=0.6" + request.env['HTTP_ACCEPT_LANGUAGE'] = accept_language + get :frontpage + response.should have_tag('html[lang="es"]') + request.env['HTTP_ACCEPT_LANGUAGE'] = nil + end + it "doesn't raise an error when there's no user matching the one in the session" do session[:user_id] = 999 get :frontpage |