Sha256: 0ab5a6e3d8247655f891002b29c97460d8d10a38875be690b817822a48aa9cb1

Contents?: true

Size: 1.07 KB

Versions: 52

Compression:

Stored size: 1.07 KB

Contents

require File.expand_path("../spec_helper", File.dirname(__FILE__))

FastGettext.silence_errors

describe ActionController::Base do
  before do
    #controller
    @c = ActionController::Base.new
    fake_session = {}
    @c.stub!(:session).and_return fake_session
    fake_cookies = {}
    @c.stub!(:cookies).and_return fake_cookies
    @c.params = {}
    @c.request = stub(:env => {})

    #locale
    FastGettext.available_locales = nil
    FastGettext.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 "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

52 entries across 52 versions & 2 rubygems

Version Path
zena-1.2.8 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-1.2.7 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-1.2.6 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-1.2.5 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-1.2.4 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-1.2.3 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-1.2.2 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-1.2.1 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-1.2.0 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
gettext_i18n_rails-0.3.4 spec/gettext_i18n_rails/action_controller_spec.rb
gettext_i18n_rails-0.3.3 spec/gettext_i18n_rails/action_controller_spec.rb
gettext_i18n_rails-0.3.2 spec/gettext_i18n_rails/action_controller_spec.rb
gettext_i18n_rails-0.3.1 spec/gettext_i18n_rails/action_controller_spec.rb
zena-1.1.3 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-1.1.2 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
gettext_i18n_rails-0.3.0 spec/gettext_i18n_rails/action_controller_spec.rb
zena-1.1.1 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-1.1.0 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-1.0.0 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
gettext_i18n_rails-0.2.20 spec/gettext_i18n_rails/action_controller_spec.rb