Sha256: dcf248a00f94d1217e75f7cbcef65051679bcbb4aa4c4975b60d155ad2db2c1d

Contents?: true

Size: 974 Bytes

Versions: 13

Compression:

Stored size: 974 Bytes

Contents

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

FastGettext.silence_errors

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

    #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.stubs(:env).returns '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

13 entries across 13 versions & 1 rubygems

Version Path
zena-0.16.9 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-0.16.8 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-0.16.7 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-0.16.6 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-0.16.5 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-0.16.4 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-0.16.3 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-0.16.2 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-0.16.1 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-0.16.0 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-0.15.2 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-0.15.1 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb
zena-0.15.0 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/action_controller_spec.rb