aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorAndrey A.I. Sitnik <andrey@sitnik.ru>2011-12-23 21:29:49 +0700
committerJosé Valim <jose.valim@gmail.com>2011-12-24 09:42:34 +0100
commit7b1ac55f50bd580a8a9c6e9bfa8b178f1ab6f443 (patch)
tree5a67cd402d1fda5fd48ff030edbc22430c3bebe6 /actionpack/test/controller
parent7c42b9321a8c7e47304f62e9cec8ad2d9019decf (diff)
downloadrails-7b1ac55f50bd580a8a9c6e9bfa8b178f1ab6f443.tar.gz
rails-7b1ac55f50bd580a8a9c6e9bfa8b178f1ab6f443.tar.bz2
rails-7b1ac55f50bd580a8a9c6e9bfa8b178f1ab6f443.zip
Gzip files on page caching
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/caching_test.rb41
1 files changed, 40 insertions, 1 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 015e6b9955..dfebb29da3 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -17,6 +17,9 @@ class PageCachingTestController < CachingController
caches_page :ok, :no_content, :if => Proc.new { |c| !c.request.format.json? }
caches_page :found, :not_found
caches_page :about_me
+ caches_page :default_gzip
+ caches_page :no_gzip, :gzip => false
+ caches_page :gzip_level, :gzip => :best_speed
def ok
@@ -40,6 +43,18 @@ class PageCachingTestController < CachingController
cache_page("Super soaker", "/index.html")
end
+ def default_gzip
+ render :text => "Text"
+ end
+
+ def no_gzip
+ render :text => "PNG"
+ end
+
+ def gzip_level
+ render :text => "Big text"
+ end
+
def expire_custom_path
expire_page("/index.html")
head :ok
@@ -115,6 +130,30 @@ class PageCachingTest < ActionController::TestCase
assert !File.exist?("#{FILE_STORE_PATH}/index.html")
end
+ def test_should_gzip_cache
+ get :custom_path
+ assert File.exist?("#{FILE_STORE_PATH}/index.html.gz")
+
+ get :expire_custom_path
+ assert !File.exist?("#{FILE_STORE_PATH}/index.html.gz")
+ end
+
+ def test_should_allow_to_disable_gzip
+ get :no_gzip
+ assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/no_gzip.html")
+ assert !File.exist?("#{FILE_STORE_PATH}/page_caching_test/no_gzip.html.gz")
+ end
+
+ def test_should_use_best_gzip_by_default
+ @controller.expects(:cache_page).with(nil, nil, Zlib::BEST_COMPRESSION)
+ get :default_gzip
+ end
+
+ def test_should_set_gzip_level
+ @controller.expects(:cache_page).with(nil, nil, Zlib::BEST_SPEED)
+ get :gzip_level
+ end
+
def test_should_cache_without_trailing_slash_on_url
@controller.class.cache_page 'cached content', '/page_caching_test/trailing_slash'
assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/trailing_slash.html")
@@ -224,7 +263,7 @@ class ActionCachingTestController < CachingController
@cache_this = MockTime.now.to_f.to_s
render :text => @cache_this
end
-
+
def record_not_found
raise ActiveRecord::RecordNotFound, "oops!"
end