Skip to content

Commit

Permalink
Do not track if main resource does not respond to updated_at
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed May 7, 2011
1 parent 65533ee commit 5bcb0e1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/responders/http_cache_responder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def do_http_cache!

def do_http_cache?
get? && @http_cache != false && ActionController::Base.perform_caching &&
!new_record? && controller.response.last_modified.nil?
!new_record? && controller.response.last_modified.nil? && resource.respond_to?(:updated_at)
end

def new_record?
Expand Down
9 changes: 2 additions & 7 deletions test/http_cache_responder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ def test_does_not_use_cache_if_last_modified_already_set_in_response
assert_equal 200, @response.status
end

def test_collection_chooses_the_latest_timestamp
def test_collection_does_not_trigger_http_cache
get :collection
assert_equal Time.utc(2009).httpdate, @response.headers["Last-Modified"]
assert_equal nil, @response.headers["Last-Modified"]
assert_match /xml/, @response.body
assert_equal 200, @response.status
end
Expand All @@ -108,11 +108,6 @@ def test_work_with_an_empty_array
assert_equal 200, @response.status
end

def test_it_does_not_set_body_etag
get :collection
assert_nil @response.headers["ETag"]
end

def test_does_not_set_cache_for_new_records
get :new_record
assert_nil @response.headers["Last-Modified"]
Expand Down

0 comments on commit 5bcb0e1

Please sign in to comment.