diff options
author | Travis Warlick <warlickt@operissystems.com> | 2011-08-13 21:23:27 -0500 |
---|---|---|
committer | Steve Klabnik <steve@steveklabnik.com> | 2012-09-15 15:01:59 +0400 |
commit | cd461c3e64e09cdcb1e379d1c35423c5e2caa592 (patch) | |
tree | 98beac2682833974906c0f2cf8319fbe8e18747c /actionpack/test/dispatch | |
parent | 60c88e64e26682a954f7c8cd6669d409ffffcc8b (diff) | |
download | rails-cd461c3e64e09cdcb1e379d1c35423c5e2caa592.tar.gz rails-cd461c3e64e09cdcb1e379d1c35423c5e2caa592.tar.bz2 rails-cd461c3e64e09cdcb1e379d1c35423c5e2caa592.zip |
Support for multiple etags in an If-None-Match header
This is a rebased version of #2520.
Conflicts:
actionpack/test/dispatch/request_test.rb
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r-- | actionpack/test/dispatch/request_test.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb index a434e49dbd..a2b9571660 100644 --- a/actionpack/test/dispatch/request_test.rb +++ b/actionpack/test/dispatch/request_test.rb @@ -746,6 +746,45 @@ class RequestTest < ActiveSupport::TestCase assert_equal "/foo?bar", path end + test "if_none_match_etags none" do + request = stub_request + + assert_equal nil, request.if_none_match + assert_equal [], request.if_none_match_etags + assert !request.etag_matches?("foo") + assert !request.etag_matches?(nil) + end + + test "if_none_match_etags single" do + header = 'the-etag' + request = stub_request('HTTP_IF_NONE_MATCH' => header) + + assert_equal header, request.if_none_match + assert_equal [header], request.if_none_match_etags + assert request.etag_matches?("the-etag") + end + + test "if_none_match_etags quoted single" do + header = '"the-etag"' + request = stub_request('HTTP_IF_NONE_MATCH' => header) + + assert_equal header, request.if_none_match + assert_equal ['the-etag'], request.if_none_match_etags + assert request.etag_matches?("the-etag") + end + + test "if_none_match_etags multiple" do + header = 'etag1, etag2, "third etag", "etag4"' + expected = ['etag1', 'etag2', 'third etag', 'etag4'] + request = stub_request('HTTP_IF_NONE_MATCH' => header) + + assert_equal header, request.if_none_match + assert_equal expected, request.if_none_match_etags + expected.each do |etag| + assert request.etag_matches?(etag), etag + end + end + protected def stub_request(env = {}) |