1 require File.join( File.dirname(__FILE__), '..', 'test_helper' )
 
   2 require 'globalize/i18n/missing_translations_log_handler'
 
   4 class MissingTranslationsTest < ActiveSupport::TestCase
 
   5   test "defines I18n.missing_translations_logger accessor" do
 
   6     assert I18n.respond_to?(:missing_translations_logger)
 
   9   test "defines I18n.missing_translations_logger= writer" do
 
  10     assert I18n.respond_to?(:missing_translations_logger=)
 
  14 class TestLogger < String
 
  15   def warn(msg) self.concat msg; end
 
  18 class LogMissingTranslationsTest < ActiveSupport::TestCase
 
  20     @locale, @key, @options = :en, :foo, {}
 
  21     @exception = I18n::MissingTranslationData.new(@locale, @key, @options)
 
  23     @logger = TestLogger.new
 
  24     I18n.missing_translations_logger = @logger
 
  27   test "still returns the exception message for MissingTranslationData exceptions" do
 
  28     result = I18n.send(:missing_translations_log_handler, @exception, @locale, @key, @options)
 
  29     assert_equal 'translation missing: en, foo', result 
 
  32   test "logs the missing translation to I18n.missing_translations_logger" do
 
  33     I18n.send(:missing_translations_log_handler, @exception, @locale, @key, @options)
 
  34     assert_equal 'translation missing: en, foo', @logger