Skip to content

Commit

Permalink
Merge branch 'master' of github.com:plataformatec/responders
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Dec 14, 2009
2 parents f1032f5 + c93fd58 commit 2269b23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/responders/http_cache_responder.rb
Expand Up @@ -20,8 +20,7 @@ def to_format
resource.updated_at.utc if resource.respond_to?(:updated_at)
end.compact.max

controller.response.last_modified = timestamp

controller.response.last_modified = timestamp if timestamp
if request.fresh?(controller.response)
head :not_modified
return
Expand Down
11 changes: 11 additions & 0 deletions test/http_cache_responder_test.rb
Expand Up @@ -16,6 +16,10 @@ def single
def collection
respond_with [Model.new(Time.utc(2009)), Model.new(Time.utc(2008))]
end

def empty
respond_with []
end
end

class HttpCacheResponderTest < ActionController::TestCase
Expand Down Expand Up @@ -90,4 +94,11 @@ def test_collection_chooses_the_latest_timestamp
assert_match /xml/, @response.body
assert_equal 200, @response.status
end

def test_work_with_an_empty_array
get :empty
assert_nil @response.headers["Last-Modified"]
assert_match /xml/, @response.body
assert_equal 200, @response.status
end
end

0 comments on commit 2269b23

Please sign in to comment.