aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionview/test')
-rw-r--r--actionview/test/template/translation_helper_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/actionview/test/template/translation_helper_test.rb b/actionview/test/template/translation_helper_test.rb
index 362f05ea70..0eccfed8f6 100644
--- a/actionview/test/template/translation_helper_test.rb
+++ b/actionview/test/template/translation_helper_test.rb
@@ -1,11 +1,20 @@
require 'abstract_unit'
+module I18n
+ class CustomExceptionHandler
+ def self.call(exception, locale, key, options)
+ 'from CustomExceptionHandler'
+ end
+ end
+end
+
class TranslationHelperTest < ActiveSupport::TestCase
include ActionView::Helpers::TranslationHelper
attr_reader :request, :view
setup do
+ I18n.exception_handler = nil
I18n.backend.store_translations(:en,
:translations => {
:templates => {
@@ -72,6 +81,16 @@ class TranslationHelperTest < ActiveSupport::TestCase
end
end
+ def test_uses_custom_exception_handler_when_specified
+ I18n.exception_handler = I18n::CustomExceptionHandler
+ assert_equal 'from CustomExceptionHandler', translate(:"translations.missing", raise: false)
+ end
+
+ def test_uses_custom_exception_handler_when_specified_for_html
+ I18n.exception_handler = I18n::CustomExceptionHandler
+ assert_equal 'from CustomExceptionHandler', translate(:"translations.missing_html", raise: false)
+ end
+
def test_i18n_translate_defaults_to_nil_rescue_format
expected = 'translation missing: en.translations.missing'
assert_equal expected, I18n.translate(:"translations.missing")