From b6f3ef10aac610aea1ca75b47cec16fcfc9f1702 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 11 Mar 2013 20:57:45 +0100 Subject: [PATCH] Resource can be nil in Responders::Image --- lib/travis/api/app/responders/image.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app/responders/image.rb b/lib/travis/api/app/responders/image.rb index 09b7a5a1..604094cf 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, last_modified: resource.last_build_finished_at) + halt send_file(filename, type: :png, last_modified: last_modified) end private @@ -24,5 +24,10 @@ module Travis::Api::App::Responders def root File.expand_path('.') # TODO wat. end + + def last_modified + resource ? resource.last_build_finished_at : nil + end + end end