From a98cd7ca9b2f24a4500963e58ba5c37d6bdf9259 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 25 Jan 2009 22:50:02 -0600 Subject: Add localized templates # Default locale app/views/messages/index.html.erb # I18n.locale is set to :da (Danish) app/views/messages/index.da.html.erb --- actionpack/test/abstract_unit.rb | 4 ++++ actionpack/test/fixtures/test/hello_world.da.html.erb | 1 + actionpack/test/template/render_test.rb | 15 +++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 actionpack/test/fixtures/test/hello_world.da.html.erb (limited to 'actionpack/test') diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 30e2d863d0..4baebcb4d1 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -32,6 +32,10 @@ ActionController::Routing::Routes.reload rescue nil ActionController::Base.session_store = nil +# Register danish language for testing +I18n.backend.store_translations 'da', {} +ORIGINAL_LOCALES = I18n.available_locales + FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures') ActionController::Base.view_paths = FIXTURE_LOAD_PATH diff --git a/actionpack/test/fixtures/test/hello_world.da.html.erb b/actionpack/test/fixtures/test/hello_world.da.html.erb new file mode 100644 index 0000000000..10ec443291 --- /dev/null +++ b/actionpack/test/fixtures/test/hello_world.da.html.erb @@ -0,0 +1 @@ +Hey verden \ No newline at end of file diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 4bd897efeb..c226e212b5 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -5,6 +5,13 @@ module RenderTestCases def setup_view(paths) @assigns = { :secret => 'in the sauce' } @view = ActionView::Base.new(paths, @assigns) + + # Reload and register danish language for testing + I18n.reload! + I18n.backend.store_translations 'da', {} + + # Ensure original are still the same since we are reindexing view paths + assert_equal ORIGINAL_LOCALES, I18n.available_locales end def test_render_file @@ -19,6 +26,14 @@ module RenderTestCases assert_equal "Hello world!", @view.render(:file => "test/hello_world") end + def test_render_file_with_localization + 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_at_top_level assert_equal 'Elastica', @view.render(:file => '/shared') end -- cgit v1.2.3