aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/abstract/localized_cache_test.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-10-28 10:33:05 -0200
committerYehuda Katz <wycats@gmail.com>2009-11-01 02:23:49 +0100
commit976c2647240fd40a2b706ab5e41856cd47e7b212 (patch)
tree424a54f1b025cf8e3d17dcd15632d68eb62a78ef /actionpack/test/abstract/localized_cache_test.rb
parenta107103e85a2cc294faedddbb44707fd2bc2e206 (diff)
downloadrails-976c2647240fd40a2b706ab5e41856cd47e7b212.tar.gz
rails-976c2647240fd40a2b706ab5e41856cd47e7b212.tar.bz2
rails-976c2647240fd40a2b706ab5e41856cd47e7b212.zip
Extracted localized_cache.rb from ActionController, added it to AbstractController and made ActionMailer use it.
Diffstat (limited to 'actionpack/test/abstract/localized_cache_test.rb')
-rw-r--r--actionpack/test/abstract/localized_cache_test.rb57
1 files changed, 57 insertions, 0 deletions
diff --git a/actionpack/test/abstract/localized_cache_test.rb b/actionpack/test/abstract/localized_cache_test.rb
new file mode 100644
index 0000000000..6f9bb693f7
--- /dev/null
+++ b/actionpack/test/abstract/localized_cache_test.rb
@@ -0,0 +1,57 @@
+require 'abstract_unit'
+
+module AbstractController
+ module Testing
+
+ class CachedController < AbstractController::Base
+ include AbstractController::RenderingController
+ include AbstractController::LocalizedCache
+
+ self.view_paths = [ActionView::FixtureResolver.new(
+ "default.erb" => "With Default",
+ "template.erb" => "With Template",
+ "some/file.erb" => "With File",
+ "template_name.erb" => "With Template Name"
+ )]
+ end
+
+ class TestLocalizedCache < ActiveSupport::TestCase
+
+ def setup
+ @controller = CachedController.new
+ CachedController.clear_template_caches!
+ end
+
+ def test_templates_are_cached
+ @controller.render :template => "default.erb"
+ assert_equal "With Default", @controller.response_body
+
+ cached = @controller.class.template_cache
+ assert_equal 1, cached.size
+ assert_kind_of ActionView::Template, cached.values.first["default.erb"]
+ end
+
+ def test_cache_is_used
+ CachedController.new.render :template => "default.erb"
+
+ @controller.expects(:find_template).never
+ @controller.render :template => "default.erb"
+
+ assert_equal 1, @controller.class.template_cache.size
+ end
+
+ def test_cache_changes_with_locale
+ CachedController.new.render :template => "default.erb"
+
+ I18n.locale = :es
+ @controller.render :template => "default.erb"
+
+ assert_equal 2, @controller.class.template_cache.size
+ ensure
+ I18n.locale = :en
+ end
+
+ end
+
+ end
+end