aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-05-28 16:00:32 +0200
committerYves Senn <yves.senn@gmail.com>2014-05-28 16:00:32 +0200
commitb22b1882238b08ed341bebc32335b6b6f6f64dfb (patch)
tree1e23c112f1192fed131bb83ec5556faeb8c3926d /actionpack
parent0f80a5262964c27b3204c8179d37f91c64ceb6f6 (diff)
parent1407315423782f9512f73f5111cb27d9bc11cff6 (diff)
downloadrails-b22b1882238b08ed341bebc32335b6b6f6f64dfb.tar.gz
rails-b22b1882238b08ed341bebc32335b6b6f6f64dfb.tar.bz2
rails-b22b1882238b08ed341bebc32335b6b6f6f64dfb.zip
Merge pull request #15383 from zuhao/refactor_actionpack_localized_templates_test
Move I18n.locale setting into setup and teardown.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/test/controller/localized_templates_test.rb18
1 files changed, 8 insertions, 10 deletions
diff --git a/actionpack/test/controller/localized_templates_test.rb b/actionpack/test/controller/localized_templates_test.rb
index c95ef8a0c7..27871ef351 100644
--- a/actionpack/test/controller/localized_templates_test.rb
+++ b/actionpack/test/controller/localized_templates_test.rb
@@ -8,22 +8,24 @@ end
class LocalizedTemplatesTest < ActionController::TestCase
tests LocalizedController
+ setup do
+ @old_locale = I18n.locale
+ end
+
+ teardown do
+ I18n.locale = @old_locale
+ end
+
def test_localized_template_is_used
- old_locale = I18n.locale
I18n.locale = :de
get :hello_world
assert_equal "Gutten Tag", @response.body
- ensure
- I18n.locale = old_locale
end
def test_default_locale_template_is_used_when_locale_is_missing
- old_locale = I18n.locale
I18n.locale = :dk
get :hello_world
assert_equal "Hello World", @response.body
- ensure
- I18n.locale = old_locale
end
def test_use_fallback_locales
@@ -36,13 +38,9 @@ class LocalizedTemplatesTest < ActionController::TestCase
end
def test_localized_template_has_correct_header_with_no_format_in_template_name
- old_locale = I18n.locale
I18n.locale = :it
-
get :hello_world
assert_equal "Ciao Mondo", @response.body
assert_equal "text/html", @response.content_type
- ensure
- I18n.locale = old_locale
end
end