Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
a404834b75
3 changed files with 43 additions and 0 deletions
|
@ -81,6 +81,18 @@ class FileControllerTest < ActionController::TestCase
|
||||||
assert_equal 'inline; filename="rails.gif"', r.headers['Content-Disposition']
|
assert_equal 'inline; filename="rails.gif"', r.headers['Content-Disposition']
|
||||||
end
|
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
|
def test_pic_unknown_pic
|
||||||
r = get :file, :web => 'wiki1', :id => 'non-existant.gif'
|
r = get :file, :web => 'wiki1', :id => 'non-existant.gif'
|
||||||
|
|
||||||
|
|
|
@ -164,6 +164,31 @@ class StubUrlGenerator < AbstractUrlGenerator
|
||||||
end
|
end
|
||||||
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}</#{media_type}>}
|
||||||
|
else
|
||||||
|
text
|
||||||
|
end
|
||||||
|
when :publish
|
||||||
|
if known_media
|
||||||
|
%{<#{media_type} src="../file/#{link}" controls="controls">#{text}</#{media_type}>}
|
||||||
|
else
|
||||||
|
%{<span class="newWikiWord">#{text}</span>}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if known_media
|
||||||
|
%{<#{media_type} src="../file/#{link}" controls="controls">#{text}</#{media_type}>}
|
||||||
|
else
|
||||||
|
%{<span class="newWikiWord">#{text}<a href="../file/#{link}">?</a></span>}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
module Test
|
module Test
|
||||||
module Unit
|
module Unit
|
||||||
module Assertions
|
module Assertions
|
||||||
|
|
|
@ -521,6 +521,12 @@ END_THM
|
||||||
assert_markup_parsed_as(
|
assert_markup_parsed_as(
|
||||||
"<p><a class='existingWikiWord' href='../file/square.jpg' title='Square'>Blue Square</a></p>",
|
"<p><a class='existingWikiWord' href='../file/square.jpg' title='Square'>Blue Square</a></p>",
|
||||||
'[[square.jpg|Blue Square:file]]')
|
'[[square.jpg|Blue Square:file]]')
|
||||||
|
assert_markup_parsed_as(
|
||||||
|
"<p><video controls='controls' src='../file/square.jpg'>Blue Square</video></p>",
|
||||||
|
'[[square.jpg|Blue Square:video]]')
|
||||||
|
assert_markup_parsed_as(
|
||||||
|
"<p><audio controls='controls' src='../file/square.jpg'>Blue Square</audio></p>",
|
||||||
|
'[[square.jpg|Blue Square:audio]]')
|
||||||
assert_markup_parsed_as(
|
assert_markup_parsed_as(
|
||||||
"<p><a class='existingWikiWord' href='../file/square.jpg' title='Square'>Square</a></p>",
|
"<p><a class='existingWikiWord' href='../file/square.jpg' title='Square'>Square</a></p>",
|
||||||
'[[square.jpg:file]]')
|
'[[square.jpg:file]]')
|
||||||
|
|
Loading…
Reference in a new issue