diff --git a/test/functional/file_controller_test.rb b/test/functional/file_controller_test.rb index dbc82f9c..f3696059 100755 --- a/test/functional/file_controller_test.rb +++ b/test/functional/file_controller_test.rb @@ -81,6 +81,18 @@ class FileControllerTest < ActionController::TestCase assert_equal 'inline; filename="rails.gif"', r.headers['Content-Disposition'] end + def test_pic_x_sendfile + pic = File.open("#{RAILS_ROOT}/test/fixtures/rails.gif", 'rb') { |f| f.read } + @web.wiki_files.create(:file_name => 'rails.gif', :description => 'An image', :content => pic) + @request.env.update({ 'HTTP_X_SENDFILE_TYPE' => 'foo' }) + r = get :file, :web => 'wiki1', :id => 'rails.gif' + + assert_response(:success, bypass_body_parsing = true) + assert_match '/rails.gif', r.headers['X-Sendfile'] + assert_equal 'image/gif', r.headers['Content-Type'] + assert_equal 'inline; filename="rails.gif"', r.headers['Content-Disposition'] + end + def test_pic_unknown_pic r = get :file, :web => 'wiki1', :id => 'non-existant.gif' diff --git a/test/test_helper.rb b/test/test_helper.rb index 66a1b1e6..f38eaf6b 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -164,6 +164,31 @@ class StubUrlGenerator < AbstractUrlGenerator end end + def media_link(mode, name, text, web_address, known_media, media_type) + link = CGI.escape(name) + text = CGI.escapeHTML(CGI.unescapeHTML(text || :description)) + case mode.to_sym + when :export + if known_media + %{<#{media_type} src="#{CGI.escape(name)}" controls="controls">#{text}} + else + text + end + when :publish + if known_media + %{<#{media_type} src="../file/#{link}" controls="controls">#{text}} + else + %{#{text}} + end + else + if known_media + %{<#{media_type} src="../file/#{link}" controls="controls">#{text}} + else + %{#{text}?} + end + end + end + module Test module Unit module Assertions diff --git a/test/unit/page_renderer_test.rb b/test/unit/page_renderer_test.rb index 7fc73e4f..54b2480f 100644 --- a/test/unit/page_renderer_test.rb +++ b/test/unit/page_renderer_test.rb @@ -521,6 +521,12 @@ END_THM assert_markup_parsed_as( "

Blue Square

", '[[square.jpg|Blue Square:file]]') + assert_markup_parsed_as( + "

", + '[[square.jpg|Blue Square:video]]') + assert_markup_parsed_as( + "

", + '[[square.jpg|Blue Square:audio]]') assert_markup_parsed_as( "

Square

", '[[square.jpg:file]]')