Sha256: 18c2c2888232bd9478f1d0bf0f7e4e578edfc5b086cc36603c86bc4e4f81050e

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'abstract_unit'

class LocalizedController < ActionController::Base
  def hello_world
  end
end

class LocalizedTemplatesTest < ActionController::TestCase
  tests LocalizedController

  setup do
    @old_locale = I18n.locale
  end

  teardown do
    I18n.locale = @old_locale
  end

  def test_localized_template_is_used
    I18n.locale = :de
    get :hello_world
    assert_equal "Gutten Tag", @response.body
  end

  def test_default_locale_template_is_used_when_locale_is_missing
    I18n.locale = :dk
    get :hello_world
    assert_equal "Hello World", @response.body
  end

  def test_use_fallback_locales
    I18n.locale = :"de-AT"
    I18n.backend.class.send(:include, I18n::Backend::Fallbacks)
    I18n.fallbacks[:"de-AT"] = [:de]

    get :hello_world
    assert_equal "Gutten Tag", @response.body
  end

  def test_localized_template_has_correct_header_with_no_format_in_template_name
    I18n.locale = :it
    get :hello_world
    assert_equal "Ciao Mondo", @response.body
    assert_equal "text/html",  @response.content_type
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activejob-lock-0.0.2 rails/actionpack/test/controller/localized_templates_test.rb
activejob-lock-0.0.1 rails/actionpack/test/controller/localized_templates_test.rb