Sha256: 33933d3205a3b343f828bb7444f2e47ad8fa61ec6fa5dffba8b454b8f7780542

Contents?: true

Size: 1.2 KB

Versions: 14

Compression:

Stored size: 1.2 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'
require 'i18n/missing_translations_log_handler'

class MissingTranslationsTest < ActiveSupport::TestCase
  test "defines I18n.missing_translations_logger accessor" do
    assert I18n.respond_to?(:missing_translations_logger)
  end

  test "defines I18n.missing_translations_logger= writer" do
    assert I18n.respond_to?(:missing_translations_logger=)
  end
end

class TestLogger < String
  def warn(msg) self.concat msg; end
end

class LogMissingTranslationsTest < ActiveSupport::TestCase
  def setup
    @locale, @key, @options = :en, :foo, {}
    @exception = I18n::MissingTranslationData.new(@locale, @key, @options)

    @logger = TestLogger.new
    I18n.missing_translations_logger = @logger
  end

  test "still returns the exception message for MissingTranslationData exceptions" do
    result = I18n.send(:missing_translations_log_handler, @exception, @locale, @key, @options)
    assert_equal 'translation missing: en, foo', result
  end

  test "logs the missing translation to I18n.missing_translations_logger" do
    I18n.send(:missing_translations_log_handler, @exception, @locale, @key, @options)
    assert_equal 'translation missing: en, foo', @logger
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
radiant-globalize2-extension-0.3.2 vendor/plugins/globalize2/test/i18n/missing_translations_test.rb
radiant-globalize2-extension-0.3.1 vendor/plugins/globalize2/test/i18n/missing_translations_test.rb
radiant-globalize2-extension-0.3.0 vendor/plugins/globalize2/test/i18n/missing_translations_test.rb
radiant-globalize2-extension-0.2.8 vendor/plugins/globalize2/test/i18n/missing_translations_test.rb
radiant-globalize2-extension-0.2.7 vendor/plugins/globalize2/test/i18n/missing_translations_test.rb
radiant-globalize2-extension-0.2.6 vendor/plugins/globalize2/test/i18n/missing_translations_test.rb
radiant-globalize2-extension-0.2.5 vendor/plugins/globalize2/test/i18n/missing_translations_test.rb
radiant-globalize2-extension-0.2.4 vendor/plugins/globalize2/test/i18n/missing_translations_test.rb
radiant-globalize2-extension-0.2.3 vendor/plugins/globalize2/test/i18n/missing_translations_test.rb
radiant-globalize2-extension-0.2.2 vendor/plugins/globalize2/test/i18n/missing_translations_test.rb
radiant-globalize2-extension-0.2.1 vendor/plugins/globalize2/test/i18n/missing_translations_test.rb
radiant-globalize2-extension-0.2.0 vendor/plugins/globalize2/test/i18n/missing_translations_test.rb
globalize2-0.2.1 test/i18n/missing_translations_test.rb
globalize2-0.2.0 test/i18n/missing_translations_test.rb