Skip to content

Commit

Permalink
Ensure changes to I18n locale get reset during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Sep 19, 2009
1 parent f1c8f07 commit f5ace62
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
3 changes: 1 addition & 2 deletions actionpack/test/dispatch/show_exceptions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ class ShowExceptionsTest < ActionController::IntegrationTest

test "localize public rescue message" do
# Change locale
old_locale = I18n.locale
I18n.locale = :da
old_locale, I18n.locale = I18n.locale, :da

begin
@integration_session = open_session(ProductionApp)
Expand Down
11 changes: 8 additions & 3 deletions actionpack/test/new_base/render_rjs_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require 'abstract_unit'

module RenderRjs

class BasicController < ActionController::Base

self.view_paths = [ActionView::FixtureResolver.new(
"render_rjs/basic/index.js.rjs" => "page[:customer].replace_html render(:partial => 'customer')",
"render_rjs/basic/index_html.js.rjs" => "page[:customer].replace_html :partial => 'customer'",
Expand All @@ -26,6 +24,14 @@ def index_locale
class TestBasic < SimpleRouteCase
testing BasicController

def setup
@old_locale = I18n.locale
end

def teardown
I18n.locale = @old_locale
end

test "rendering a partial in an RJS template should pick the JS template over the HTML one" do
get :index, "format" => "js"
assert_response("$(\"customer\").update(\"JS Partial\");")
Expand All @@ -40,6 +46,5 @@ class TestBasic < SimpleRouteCase
get :index_locale, "format" => "js"
assert_response("$(\"customer\").update(\"Danish HTML Partial\");")
end

end
end
14 changes: 5 additions & 9 deletions actionpack/test/template/render_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,14 @@ def test_render_file_without_specific_extension
end

def test_render_file_with_localization
begin
old_locale = I18n.locale
I18n.locale = :da
assert_equal "Hey verden", @view.render(:file => "test/hello_world")
ensure
I18n.locale = old_locale
end
old_locale, I18n.locale = I18n.locale, :da
assert_equal "Hey verden", @view.render(:file => "test/hello_world")
ensure
I18n.locale = old_locale
end

def test_render_file_with_dashed_locale
old_locale = I18n.locale
I18n.locale = :"pt-BR"
old_locale, I18n.locale = I18n.locale, :"pt-BR"
assert_equal "Ola mundo", @view.render(:file => "test/hello_world")
ensure
I18n.locale = old_locale
Expand Down

0 comments on commit f5ace62

Please sign in to comment.