Sha256: 412ed8a3dd125f215db62e8e294c902e4bd0539fd13c9bbdada9619eb21985b5
Contents?: true
Size: 1.29 KB
Versions: 4
Compression:
Stored size: 1.29 KB
Contents
require "spec_helper" FastGettext.silence_errors describe ActionController::Base do def reset! fake_session = {} @c.stub(:session).and_return fake_session fake_cookies = {} @c.stub(:cookies).and_return fake_cookies @c.params = {} @c.request = double(:env => {}) end before do #controller @c = ActionController::Base.new reset! #locale FastGettext.available_locales = nil FastGettext.locale = I18n.default_locale = 'fr' FastGettext.available_locales = ['fr','en'] end it "changes the locale" do @c.params = {:locale=>'en'} @c.set_gettext_locale @c.session[:locale].should == 'en' FastGettext.locale.should == 'en' end it "stays with default locale when none was found" do @c.set_gettext_locale @c.session[:locale].should == 'fr' FastGettext.locale.should == 'fr' end it "locale isn't cached over request" do @c.params = {:locale=>'en'} @c.set_gettext_locale @c.session[:locale].should == 'en' reset! @c.set_gettext_locale @c.session[:locale].should == 'fr' end it "reads the locale from the HTTP_ACCEPT_LANGUAGE" do @c.request.stub(:env).and_return 'HTTP_ACCEPT_LANGUAGE'=>'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3' @c.set_gettext_locale FastGettext.locale.should == 'en' end end
Version data entries
4 entries across 4 versions & 1 rubygems