Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

last_modified ignores nil

  • Loading branch information...
commit 3ff226272a4f8d0f3e9788cbe2cf4dfd01cc868d 1 parent 035fe47
Simon Rozet sr authored
Showing with 10 additions and 0 deletions.
  1. +1 −0  lib/sinatra/base.rb
  2. +9 −0 test/helpers_test.rb
1  lib/sinatra/base.rb
View
@@ -240,6 +240,7 @@ def expires(amount, *values)
# matches the time specified, execution is immediately halted with a
# '304 Not Modified' response.
def last_modified(time)
+ return unless time
time = time.to_time if time.respond_to?(:to_time)
time = time.httpdate if time.respond_to?(:httpdate)
response['Last-Modified'] = time
9 test/helpers_test.rb
View
@@ -451,6 +451,15 @@ def send_file_app(opts={})
assert_equal 304, status
assert_equal '', body
end
+
+ it 'ignores nil' do
+ mock_app {
+ get '/' do last_modified nil; 200; end
+ }
+
+ get '/'
+ assert ! response['Last-Modified']
+ end
end
describe 'etag' do
Please sign in to comment.
Something went wrong with that request. Please try again.