class EtagRenderTest
Public Instance Methods
test_array()
click to toggle source
# File actionpack/test/controller/render_test.rb, line 524 def test_array @request.if_none_match = weak_etag([%w(1 2 3), "ab", :cde, [:f]]) get :array assert_response :not_modified @request.if_none_match = %("nomatch") get :array assert_response :success end
test_etag_reflects_implicit_template_digest()
click to toggle source
# File actionpack/test/controller/render_test.rb, line 551 def test_etag_reflects_implicit_template_digest get :with_implicit_template assert_response :ok assert_not_nil etag = @response.etag request.if_none_match = etag get :with_implicit_template assert_response :not_modified modify_template("test/with_implicit_template") do request.if_none_match = etag get :with_implicit_template assert_response :ok assert_not_equal etag, @response.etag end end
test_etag_reflects_template_digest()
click to toggle source
# File actionpack/test/controller/render_test.rb, line 534 def test_etag_reflects_template_digest get :with_template assert_response :ok assert_not_nil etag = @response.etag request.if_none_match = etag get :with_template assert_response :not_modified modify_template("test/hello_world") do request.if_none_match = etag get :with_template assert_response :ok assert_not_equal etag, @response.etag end end
test_strong_etag()
click to toggle source
# File actionpack/test/controller/render_test.rb, line 496 def test_strong_etag @request.if_none_match = strong_etag(["strong", "ab", :cde, [:f]]) get :strong assert_response :not_modified @request.if_none_match = "*" get :strong assert_response :not_modified @request.if_none_match = '"strong"' get :strong assert_response :ok @request.if_none_match = weak_etag(["strong", "ab", :cde, [:f]]) get :strong assert_response :ok end
Private Instance Methods
strong_etag(record)
click to toggle source
# File actionpack/test/controller/render_test.rb, line 573 def strong_etag(record) %("#{Digest::MD5.hexdigest(ActiveSupport::Cache.expand_cache_key(record))}") end
weak_etag(record)
click to toggle source
# File actionpack/test/controller/render_test.rb, line 569 def weak_etag(record) "W/#{strong_etag record}" end