diff --git a/Gemfile.lock b/Gemfile.lock index 190b5e2a..18dabba1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -51,7 +51,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 714090635924650998b3a3d0f18b39d9cfd46839 + revision: 751da684a3c44b2c493ebc41e9b38ff8edd5cef8 specs: travis-core (0.0.1) actionmailer (~> 3.2.3) diff --git a/lib/travis/api/app/responders/image.rb b/lib/travis/api/app/responders/image.rb index 066c0133..cb2addd5 100644 --- a/lib/travis/api/app/responders/image.rb +++ b/lib/travis/api/app/responders/image.rb @@ -6,7 +6,8 @@ module Travis::Api::App::Responders def apply headers['Expires'] = Time.now.utc.httpdate - halt send_file(filename, type: :png, disposition: :inline) + headers['Content-Disposition'] = %(inline; filename="#{File.basename(filename)}") + halt send_file(filename, type: :png) end private diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index 3b39e8bb..53cc97aa 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -26,22 +26,11 @@ end RSpec::Matchers.define :deliver_result_image_for do |name| match do |response| - actual = files.detect do |name, content| - response.body.to_s.force_encoding('ascii') == content.to_s.force_encoding('ascii') # TODO ummmmmmmm? - end - actual = actual && actual[0] - + header = response.headers['content-disposition'] failure_message_for_should do - "expected #{actual.inspect} to equal #{name.inspect}" + "expected #{response.env[:url].to_s} to return headers['content-disposition'] inline; filename=\"#{name}.png\" but it was: #{header.inspect}" end - - actual == name - end - - def files - files = Hash[*Dir['public/images/result/*.png'].map do |file| - [File.basename(file, '.png'), File.read(file)] - end.flatten] + header.to_s.should =~ /^inline; filename="#{name}\.png"$/ end end