diff options
author | Christopher Dell <chris@tigrish.com> | 2014-11-19 15:08:56 +0100 |
---|---|---|
committer | Christopher Dell <chris@tigrish.com> | 2014-11-19 16:33:50 +0100 |
commit | 4dbce79e95e3f56a9b48992dea4531493a5008cc (patch) | |
tree | 3954894ff4ff66ec601de9f45290495e395def30 /actionview/test | |
parent | 52fddcc653458456f98b3683dffd781cf00b35fe (diff) | |
download | rails-4dbce79e95e3f56a9b48992dea4531493a5008cc.tar.gz rails-4dbce79e95e3f56a9b48992dea4531493a5008cc.tar.bz2 rails-4dbce79e95e3f56a9b48992dea4531493a5008cc.zip |
Fix I18n regression introduced by #13832
Previously, when the `:raise` options was set to `false`, it would get overwritten to `true`, preventing custom exception handlers to be used.
Diffstat (limited to 'actionview/test')
-rw-r--r-- | actionview/test/template/translation_helper_test.rb | 19 |
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") |