[BUILD STILL BROKEN] File uploads roughly speaking work (to about same extent as in 0.10)
This commit is contained in:
parent
ac72f9b807
commit
0b1a80a852
13 changed files with 172 additions and 297 deletions
|
@ -16,6 +16,7 @@ class FileControllerTest < Test::Unit::TestCase
|
|||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
@web = webs(:test_wiki)
|
||||
@wiki = Wiki.new
|
||||
WikiFile.delete_all
|
||||
require 'fileutils'
|
||||
FileUtils.rm_rf("#{RAILS_ROOT}/public/wiki1/files/*")
|
||||
|
@ -61,37 +62,40 @@ class FileControllerTest < Test::Unit::TestCase
|
|||
assert_equal pic, r.body
|
||||
end
|
||||
|
||||
# def test_pic_unknown_pic
|
||||
# r = process 'pic', 'web' => 'wiki1', 'id' => 'non-existant.gif'
|
||||
#
|
||||
# assert_success
|
||||
# assert_rendered_file 'file/file'
|
||||
# end
|
||||
#
|
||||
# def test_pic_upload_end_to_end
|
||||
# # edit and re-render home page so that it has an "unknown file" link to 'rails-e2e.gif'
|
||||
# @wiki.revise_page('wiki1', 'HomePage', '[[rails-e2e.gif:pic]]', Time.now, 'AnonymousBrave')
|
||||
# assert_equal "<p><span class=\"newWikiWord\">rails-e2e.gif<a href=\"../pic/rails-e2e.gif\">" +
|
||||
# "?</a></span></p>",
|
||||
# @home.display_content
|
||||
#
|
||||
# # rails-e2e.gif is unknown to the system, so pic action goes to the file [upload] form
|
||||
# r = process 'pic', 'web' => 'wiki1', 'id' => 'rails-e2e.gif'
|
||||
# assert_success
|
||||
# assert_rendered_file 'file/file'
|
||||
#
|
||||
# # User uploads the picture
|
||||
# picture = File.read("#{RAILS_ROOT}/test/fixtures/rails.gif")
|
||||
# r = process 'pic', 'web' => 'wiki1', 'id' => 'rails-e2e.gif', 'file' => StringIO.new(picture)
|
||||
# assert_redirect_url '/'
|
||||
# assert @wiki.file_yard(@web).has_file?('rails-e2e.gif')
|
||||
# assert_equal(picture, File.read("#{RAILS_ROOT}/storage/test/wiki1/rails-e2e.gif"))
|
||||
#
|
||||
# # this should refresh the page display content (cached)
|
||||
# assert_equal "<p><img alt=\"rails-e2e.gif\" src=\"../pic/rails-e2e.gif\" /></p>",
|
||||
# @home.display_content
|
||||
# end
|
||||
#
|
||||
def test_pic_unknown_pic
|
||||
r = get :file, :web => 'wiki1', :id => 'non-existant.gif'
|
||||
|
||||
assert_success
|
||||
assert_rendered_file 'file/file'
|
||||
end
|
||||
|
||||
def test_pic_upload_end_to_end
|
||||
# edit and re-render home page so that it has an "unknown file" link to 'rails-e2e.gif'
|
||||
PageRenderer.setup_url_generator(StubUrlGenerator.new)
|
||||
renderer = PageRenderer.new
|
||||
@wiki.revise_page('wiki1', 'HomePage', '[[rails-e2e.gif:pic]]',
|
||||
Time.now, 'AnonymousBrave', renderer)
|
||||
assert_equal "<p><span class=\"newWikiWord\">rails-e2e.gif<a href=\"../file/rails-e2e.gif\">" +
|
||||
"?</a></span></p>",
|
||||
renderer.display_content
|
||||
|
||||
# rails-e2e.gif is unknown to the system, so pic action goes to the file [upload] form
|
||||
r = get :file, :web => 'wiki1', :id => 'rails-e2e.gif'
|
||||
assert_success
|
||||
assert_rendered_file 'file/file'
|
||||
|
||||
# User uploads the picture
|
||||
picture = File.read("#{RAILS_ROOT}/test/fixtures/rails.gif")
|
||||
r = get :file, :web => 'wiki1', :id => 'rails-e2e.gif', :file => StringIO.new(picture)
|
||||
assert_redirect_url '/'
|
||||
assert @web.has_file?('rails-e2e.gif')
|
||||
assert_equal(picture, File.read("#{RAILS_ROOT}/public/file/rails-e2e.gif"))
|
||||
|
||||
# this should refresh the page display content (cached)
|
||||
assert_equal "<p><img alt=\"rails-e2e.gif\" src=\"../pic/rails-e2e.gif\" /></p>",
|
||||
@home.display_content
|
||||
end
|
||||
|
||||
# def test_pic_upload_end_to_end
|
||||
# # edit and re-render home page so that it has an "unknown file" link to 'rails-e2e.gif'
|
||||
# @wiki.revise_page('wiki1', 'HomePage', '[[instiki-e2e.txt:file]]', Time.now, 'AnonymousBrave',
|
||||
|
|
|
@ -150,8 +150,8 @@ class StubUrlGenerator < AbstractUrlGenerator
|
|||
if known_pic then %{<img alt="#{text}" src="#{link}" />}
|
||||
else %{<span class="newWikiWord">#{text}</span>} end
|
||||
else
|
||||
if known_pic then %{<img alt="#{text}" src="../pic/#{link}" />}
|
||||
else %{<span class="newWikiWord">#{text}<a href="../pic/#{link}">?</a></span>} end
|
||||
if known_pic then %{<img alt="#{text}" src="../file/#{link}" />}
|
||||
else %{<span class="newWikiWord">#{text}<a href="../file/#{link}">?</a></span>} end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -282,20 +282,20 @@ class PageRendererTest < Test::Unit::TestCase
|
|||
FileUtils.rm_rf("#{RAILS_ROOT}/public/wiki1/files/*")
|
||||
@web.wiki_files.create(:file_name => 'square.jpg', :description => 'Square', :content => 'never mind')
|
||||
assert_markup_parsed_as(
|
||||
'<p><img alt="Square" src="../pic/square.jpg" /></p>',
|
||||
'<p><img alt="Square" src="../file/square.jpg" /></p>',
|
||||
'[[square.jpg|Square:pic]]')
|
||||
assert_markup_parsed_as(
|
||||
'<p><img alt="square.jpg" src="../pic/square.jpg" /></p>',
|
||||
'<p><img alt="square.jpg" src="../file/square.jpg" /></p>',
|
||||
'[[square.jpg:pic]]')
|
||||
end
|
||||
|
||||
def test_link_to_non_existant_pic
|
||||
assert_markup_parsed_as(
|
||||
'<p><span class="newWikiWord">NonExistant<a href="../pic/NonExistant.jpg">?</a>' +
|
||||
'<p><span class="newWikiWord">NonExistant<a href="../file/NonExistant.jpg">?</a>' +
|
||||
'</span></p>',
|
||||
'[[NonExistant.jpg|NonExistant:pic]]')
|
||||
assert_markup_parsed_as(
|
||||
'<p><span class="newWikiWord">NonExistant.jpg<a href="../pic/NonExistant.jpg">?</a>' +
|
||||
'<p><span class="newWikiWord">NonExistant.jpg<a href="../file/NonExistant.jpg">?</a>' +
|
||||
'</span></p>',
|
||||
'[[NonExistant.jpg:pic]]')
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue