aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/translation_helper_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-01-05 14:35:50 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-01-05 14:35:50 -0300
commitd76bf34b044bb79a82a54a646016797760f8ff6e (patch)
tree39906d2200e14d1b93bd1f22600173a703ebeb8f /actionview/test/template/translation_helper_test.rb
parentf493a4122ebf44a44b93c02804d33a0e4121d6cd (diff)
parent4dbce79e95e3f56a9b48992dea4531493a5008cc (diff)
downloadrails-d76bf34b044bb79a82a54a646016797760f8ff6e.tar.gz
rails-d76bf34b044bb79a82a54a646016797760f8ff6e.tar.bz2
rails-d76bf34b044bb79a82a54a646016797760f8ff6e.zip
Merge pull request #17676 from tigrish/fix_custom_i18n_exception_handler_regression
Fix I18n regression introduced by #13832
Diffstat (limited to 'actionview/test/template/translation_helper_test.rb')
-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 dea861c0e5..7a3c0a0715 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")