Skip to content

Commit

Permalink
Avoid changing the global state on the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Jan 5, 2015
1 parent d76bf34 commit 1c81926
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion actionview/test/template/translation_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class TranslationHelperTest < ActiveSupport::TestCase
attr_reader :request, :view

setup do
I18n.exception_handler = nil
I18n.backend.store_translations(:en,
:translations => {
:templates => {
Expand Down Expand Up @@ -82,13 +81,19 @@ def test_raises_missing_translation_message_with_raise_option
end

def test_uses_custom_exception_handler_when_specified
old_exception_handler = I18n.exception_handler
I18n.exception_handler = I18n::CustomExceptionHandler
assert_equal 'from CustomExceptionHandler', translate(:"translations.missing", raise: false)
ensure
I18n.exception_handler = old_exception_handler
end

def test_uses_custom_exception_handler_when_specified_for_html
old_exception_handler = I18n.exception_handler
I18n.exception_handler = I18n::CustomExceptionHandler
assert_equal 'from CustomExceptionHandler', translate(:"translations.missing_html", raise: false)
ensure
I18n.exception_handler = old_exception_handler
end

def test_i18n_translate_defaults_to_nil_rescue_format
Expand Down

0 comments on commit 1c81926

Please sign in to comment.