1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Make sure last_modified! works with <= rather than just equality.

This commit is contained in:
Michael Koziarski 2008-10-07 21:09:07 +02:00
parent 5556db22c5
commit aec391621b
2 changed files with 9 additions and 1 deletions

View file

@ -969,7 +969,9 @@ module ActionController #:nodoc:
# If-Modified-Since request header is <= last modified. # If-Modified-Since request header is <= last modified.
def last_modified!(utc_time) def last_modified!(utc_time)
response.last_modified= utc_time response.last_modified= utc_time
head(:not_modified) if response.last_modified == request.if_modified_since if request.if_modified_since && request.if_modified_since <= utc_time
head(:not_modified)
end
end end
# Sets the ETag response header. Returns 304 Not Modified if the # Sets the ETag response header. Returns 304 Not Modified if the

View file

@ -1441,6 +1441,12 @@ class LastModifiedRenderTest < Test::Unit::TestCase
get :conditional_hello_with_bangs get :conditional_hello_with_bangs
assert_response :not_modified assert_response :not_modified
end end
def test_last_modified_works_with_less_than_too
@request.if_modified_since = 5.years.ago.httpdate
get :conditional_hello_with_bangs
assert_response :not_modified
end
end end
class RenderingLoggingTest < Test::Unit::TestCase class RenderingLoggingTest < Test::Unit::TestCase