test result images based on the content-disposition header, fix content-disposition header
This commit is contained in:
parent
88363423f4
commit
de16fb07f8
|
@ -51,7 +51,7 @@ GIT
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/travis-ci/travis-core.git
|
remote: git://github.com/travis-ci/travis-core.git
|
||||||
revision: 714090635924650998b3a3d0f18b39d9cfd46839
|
revision: 751da684a3c44b2c493ebc41e9b38ff8edd5cef8
|
||||||
specs:
|
specs:
|
||||||
travis-core (0.0.1)
|
travis-core (0.0.1)
|
||||||
actionmailer (~> 3.2.3)
|
actionmailer (~> 3.2.3)
|
||||||
|
|
|
@ -6,7 +6,8 @@ module Travis::Api::App::Responders
|
||||||
|
|
||||||
def apply
|
def apply
|
||||||
headers['Expires'] = Time.now.utc.httpdate
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -26,22 +26,11 @@ end
|
||||||
|
|
||||||
RSpec::Matchers.define :deliver_result_image_for do |name|
|
RSpec::Matchers.define :deliver_result_image_for do |name|
|
||||||
match do |response|
|
match do |response|
|
||||||
actual = files.detect do |name, content|
|
header = response.headers['content-disposition']
|
||||||
response.body.to_s.force_encoding('ascii') == content.to_s.force_encoding('ascii') # TODO ummmmmmmm?
|
|
||||||
end
|
|
||||||
actual = actual && actual[0]
|
|
||||||
|
|
||||||
failure_message_for_should do
|
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
|
end
|
||||||
|
header.to_s.should =~ /^inline; filename="#{name}\.png"$/
|
||||||
actual == name
|
|
||||||
end
|
|
||||||
|
|
||||||
def files
|
|
||||||
files = Hash[*Dir['public/images/result/*.png'].map do |file|
|
|
||||||
[File.basename(file, '.png'), File.read(file)]
|
|
||||||
end.flatten]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user