From 04bb751b023fe3875135eeabdfb2e53ec438d0d2 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 11 Mar 2013 20:54:24 +0100 Subject: [PATCH] When serving image, return proper Last-Modified header --- lib/travis/api/app/responders/image.rb | 2 +- spec/integration/v2/repositories_spec.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app/responders/image.rb b/lib/travis/api/app/responders/image.rb index c75a752f..09b7a5a1 100644 --- a/lib/travis/api/app/responders/image.rb +++ b/lib/travis/api/app/responders/image.rb @@ -8,7 +8,7 @@ module Travis::Api::App::Responders headers['Pragma'] = "no-cache" headers['Expires'] = Time.now.utc.httpdate headers['Content-Disposition'] = %(inline; filename="#{File.basename(filename)}") - halt send_file(filename, type: :png) + halt send_file(filename, type: :png, last_modified: resource.last_build_finished_at) end private diff --git a/spec/integration/v2/repositories_spec.rb b/spec/integration/v2/repositories_spec.rb index 9de7ad63..0d7c6e9c 100644 --- a/spec/integration/v2/repositories_spec.rb +++ b/spec/integration/v2/repositories_spec.rb @@ -115,6 +115,7 @@ describe 'Repos' do Factory(:build, repository: repo, state: :passed, commit: on_bar) result = get('/repos/svenfuchs/minimal.png?branch=foo,bar', {}, headers) result.should deliver_result_image_for('passing') + result.headers['Last-Modified'].should == repo.last_build_finished_at.httpdate end it '"passing" when there is a running build but the previous one has passed' do