Sha256: db00605d0dd386cd820e079dfc4d938a3aad32e95f094ef64a0a3719ec20ed54
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
require 'helper' describe "RackUserLocale" do before do I18n.default_locale = :en end it "should have I18n.locale set to :en initially" do assert_equal :en, I18n.locale end describe "when a locale cookie is set" do before do get 'http://example.com/', {}, 'HTTP_COOKIE' => 'user-locale=es' end it "should have I18n.locale set to :es" do assert_equal :es, I18n.locale end it "should not set a cookie in the response" do assert_equal nil, last_response["Set-Cookie"] end end describe "when from HTTP_ACCEPT_LANGUAGE headers" do before do get 'http://example.com/', {}, 'HTTP_ACCEPT_LANGUAGE' => 'ru' end it "should have I18n.locale set to :ru" do assert_equal :ru, I18n.locale end it "should set a cookie in the response" do assert_equal "user-locale=ru; domain=example.com; path=/", last_response["Set-Cookie"] end end describe "when both a cooke and HTTP_ACCEPT_LANGUAGE headers are set" do before do get 'http://example.com/', {}, 'HTTP_COOKIE' => 'user-locale=jp', 'HTTP_ACCEPT_LANGUAGE' => 'fr' end it "should have I18n.locale set to :jp" do assert_equal :jp, I18n.locale end it "should not set a cookie in the response" do assert_equal nil, last_response["Set-Cookie"] end end describe "when nothing is changed" do before do get 'http://example.com/' end it "should have I18n.locale set to :en" do assert_equal :en, I18n.locale end it "should set a cookie in the response" do assert_equal "user-locale=en; domain=example.com; path=/", last_response["Set-Cookie"] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack-user-locale-0.0.0 | test/test_rack-user-locale.rb |