mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Test that #fresh_when accepts an array
https://github.com/rails/etagger/pull/3
This commit is contained in:
parent
33283c98ed
commit
ca0275d36b
1 changed files with 19 additions and 2 deletions
|
@ -32,6 +32,10 @@ class TestControllerWithExtraEtags < ActionController::Base
|
||||||
def fresh
|
def fresh
|
||||||
render text: "stale" if stale?(etag: '123')
|
render text: "stale" if stale?(etag: '123')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def array
|
||||||
|
render text: "stale" if stale?(etag: %w(1 2 3))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestController < ActionController::Base
|
class TestController < ActionController::Base
|
||||||
|
@ -1649,7 +1653,6 @@ class LastModifiedRenderTest < ActionController::TestCase
|
||||||
assert_equal @last_modified, @response.headers['Last-Modified']
|
assert_equal @last_modified, @response.headers['Last-Modified']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def test_request_with_bang_gets_last_modified
|
def test_request_with_bang_gets_last_modified
|
||||||
get :conditional_hello_with_bangs
|
get :conditional_hello_with_bangs
|
||||||
assert_equal @last_modified, @response.headers['Last-Modified']
|
assert_equal @last_modified, @response.headers['Last-Modified']
|
||||||
|
@ -1678,7 +1681,7 @@ class EtagRenderTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_multiple_etags
|
def test_multiple_etags
|
||||||
@request.if_none_match = %("#{Digest::MD5.hexdigest(ActiveSupport::Cache.expand_cache_key([ "123", 'ab', :cde, [:f] ]))}")
|
@request.if_none_match = etag(["123", 'ab', :cde, [:f]])
|
||||||
get :fresh
|
get :fresh
|
||||||
assert_response :not_modified
|
assert_response :not_modified
|
||||||
|
|
||||||
|
@ -1686,6 +1689,20 @@ class EtagRenderTest < ActionController::TestCase
|
||||||
get :fresh
|
get :fresh
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_array
|
||||||
|
@request.if_none_match = 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
|
||||||
|
|
||||||
|
def etag(record)
|
||||||
|
Digest::MD5.hexdigest(ActiveSupport::Cache.expand_cache_key(record)).inspect
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue