No need to revalidate if resource is final

This commit is contained in:
Piotr Sarnacki 2012-11-01 16:15:06 +01:00
parent e2b49a91d6
commit 505b2fb911
2 changed files with 22 additions and 1 deletions

View File

@ -16,7 +16,7 @@ module Travis::Api::App::Responders
def cache_control
if final?
mode = endpoint.public? ? :public : :private
endpoint.expires(31536000, mode, :must_revalidate) # 1 year
endpoint.expires(31536000, mode) # 1 year
else
# FIXME: Chrome WTF?
endpoint.cache_control :no_cache

View File

@ -0,0 +1,21 @@
require 'spec_helper'
describe Travis::Api::App::Responders::Service do
class MyService < Travis::Api::App::Responders::Service
end
let(:endpoint) { stub 'endpoint', public?: true }
let(:resource) { stub 'resource', run: {} }
let(:options) { {} }
let(:service) { MyService.new(endpoint, resource, options) }
context 'with final resource' do
before { resource.expects(:final?).returns(true) }
it 'caches resource for a year' do
endpoint.expects(:expires).with(31536000, :public)
service.apply
end
end
end