aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2012-08-29 15:06:30 -0500
committerDavid Heinemeier Hansson <david@loudthinking.com>2012-08-29 15:06:30 -0500
commited5c938fa36995f06d4917d9543ba78ed506bb8d (patch)
tree090908f93aef6ac69499a652d0448102de97eae3 /actionpack/test
parent502d5e24e28b3634910495d0fb71cb20b1426aee (diff)
downloadrails-ed5c938fa36995f06d4917d9543ba78ed506bb8d.tar.gz
rails-ed5c938fa36995f06d4917d9543ba78ed506bb8d.tar.bz2
rails-ed5c938fa36995f06d4917d9543ba78ed506bb8d.zip
Added controller-level etag additions that will be part of the action etag computation *Jeremy Kemper/DHH*
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/render_test.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index 3f047fc9b5..fd8f87e377 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -22,6 +22,18 @@ module Quiz
end
end
+class TestControllerWithExtraEtags < ActionController::Base
+ etag { nil }
+ etag { 'ab' }
+ etag { :cde }
+ etag { [:f] }
+ etag { nil }
+
+ def fresh
+ render text: "stale" if stale?(etag: '123')
+ end
+end
+
class TestController < ActionController::Base
protect_from_forgery
@@ -1626,6 +1638,26 @@ class LastModifiedRenderTest < ActionController::TestCase
end
end
+class EtagRenderTest < ActionController::TestCase
+ tests TestControllerWithExtraEtags
+
+ def setup
+ super
+ @request.host = "www.nextangle.com"
+ end
+
+ def test_multiple_etags
+ @request.if_none_match = %("#{Digest::MD5.hexdigest(ActiveSupport::Cache.expand_cache_key([ "123", 'ab', :cde, [:f] ]))}")
+ get :fresh
+ assert_response :not_modified
+
+ @request.if_none_match = %("nomatch")
+ get :fresh
+ assert_response :success
+ end
+end
+
+
class MetalRenderTest < ActionController::TestCase
tests MetalTestController