Sync with Instiki Trunk

Sync with Revision 519 of Instiki trunk (2007/5/7).
This commit is contained in:
Jacques Distler 2007-05-11 11:47:38 -05:00
parent b0e063451f
commit 3b6cd309ff
21 changed files with 173 additions and 158 deletions

View file

@ -55,14 +55,14 @@ class AdminControllerTest < Test::Unit::TestCase
assert_equal wiki_before, @wiki
# and no new web should be created either
assert_equal old_size, @wiki.webs.size
assert_flash_has :error
assert(@response.has_flash_object?(:error))
end
def test_create_system_no_form_and_wiki_already_initialized
assert @wiki.setup?
process('create_system')
assert_redirected_to :web => @wiki.webs.keys.first, :action => 'show', :id => 'HomePage'
assert_flash_has :error
assert(@response.has_flash_object?(:error))
end

View file

@ -24,8 +24,8 @@ class FileControllerTest < Test::Unit::TestCase
def test_file_upload_form
get :file, :web => 'wiki1', :id => 'new_file.txt'
assert_success
assert_rendered_file 'file/file'
assert_response(:success)
assert_template 'file/file'
end
def test_file_download_text_file
@ -34,7 +34,7 @@ class FileControllerTest < Test::Unit::TestCase
r = get :file, :web => 'wiki1', :id => 'foo.txt'
assert_success(bypass_body_parsing = true)
assert_response(:success, bypass_body_parsing = true)
assert_equal "Contents of the file", r.body
assert_equal 'text/plain', r.headers['Content-Type']
end
@ -45,7 +45,7 @@ class FileControllerTest < Test::Unit::TestCase
r = get :file, :web => 'wiki1', :id => 'foo.pdf'
assert_success(bypass_body_parsing = true)
assert_response(:success, bypass_body_parsing = true)
assert_equal "aaa\nbbb\n", r.body
assert_equal 'application/pdf', r.headers['Content-Type']
end
@ -56,7 +56,7 @@ class FileControllerTest < Test::Unit::TestCase
r = get :file, :web => 'wiki1', :id => 'rails.gif'
assert_success(bypass_body_parsing = true)
assert_response(:success, bypass_body_parsing = true)
assert_equal 'image/gif', r.headers['Content-Type']
assert_equal pic.size, r.body.size
assert_equal pic, r.body
@ -65,8 +65,8 @@ class FileControllerTest < Test::Unit::TestCase
def test_pic_unknown_pic
r = get :file, :web => 'wiki1', :id => 'non-existant.gif'
assert_success
assert_rendered_file 'file/file'
assert_response(:success)
assert_template 'file/file'
end
def test_pic_upload_end_to_end
@ -81,12 +81,13 @@ class FileControllerTest < Test::Unit::TestCase
# 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'
assert_response(:success)
assert_template 'file/file'
# User uploads the picture
picture = File.read("#{RAILS_ROOT}/test/fixtures/rails.gif")
r = post :file, :web => 'wiki1',
# updated from post to get - post fails the spam protection (no javascript)
r = get :file, :web => 'wiki1',
:file => {:file_name => 'rails-e2e.gif', :content => StringIO.new(picture)}
assert_redirected_to({})
assert @web.has_file?('rails-e2e.gif')
@ -94,8 +95,9 @@ class FileControllerTest < Test::Unit::TestCase
end
def test_import
r = post :import, :web => 'wiki1', :file => uploaded_file("#{RAILS_ROOT}/test/fixtures/exported_markup.zip")
assert_redirect
# updated from post to get - post fails the spam protection (no javascript)
r = get :import, :web => 'wiki1', :file => uploaded_file("#{RAILS_ROOT}/test/fixtures/exported_markup.zip")
assert_response(:redirect)
assert @web.has_page?('ImportedPage')
end

View file

@ -28,7 +28,11 @@ class RoutesTest < Test::Unit::TestCase
assert_routing('web/show/%24HOME_PAGE',
:controller => 'wiki', :web => 'web', :action => 'show', :id => '$HOME_PAGE')
assert_routing('web/show/HomePage%3F',
:controller => 'wiki', :web => 'web', :action => 'show',
:id => 'HomePage')
assert_routing('web/show/HomePage%3Farg1%3Dvalue1%26arg2%3Dvalue2',
:controller => 'wiki', :web => 'web', :action => 'show',
:id => 'HomePage?arg1=value1&arg2=value2')

View file

@ -32,7 +32,7 @@ class WikiControllerTest < Test::Unit::TestCase
get :authenticate, :web => 'wiki1', :password => 'pswd'
assert_redirected_to :web => 'wiki1', :action => 'show', :id => 'HomePage'
assert_equal ['pswd'], @response.cookies['wiki1']
assert_equal ['pswd'], @response.cookies['web_address']
end
def test_authenticate_wrong_password
@ -40,7 +40,7 @@ class WikiControllerTest < Test::Unit::TestCase
r = process('authenticate', 'web' => 'wiki1', 'password' => 'wrong password')
assert_redirected_to :action => 'login', :web => 'wiki1'
assert_nil r.cookies['wiki1']
assert_nil r.cookies['web_address']
end
def test_authors
@ -50,7 +50,7 @@ class WikiControllerTest < Test::Unit::TestCase
r = process('authors', 'web' => 'wiki1')
assert_success
assert_response(:success)
assert_equal %w(AnAuthor BreakingTheOrder DavidHeinemeierHansson Guest Me TreeHugger),
r.template_objects['authors']
page_names_by_author = r.template_objects['page_names_by_author']
@ -70,7 +70,7 @@ class WikiControllerTest < Test::Unit::TestCase
def test_edit
r = process 'edit', 'web' => 'wiki1', 'id' => 'HomePage'
assert_success
assert_response(:success)
assert_equal @wiki.read_page('wiki1', 'HomePage'), r.template_objects['page']
end
@ -83,7 +83,7 @@ class WikiControllerTest < Test::Unit::TestCase
def test_edit_page_break_lock
@home.lock(Time.now, 'Locky')
process 'edit', 'web' => 'wiki1', 'id' => 'HomePage', 'break_lock' => 'y'
assert_success
assert_response(:success)
@home = Page.find(@home.id)
assert @home.locked?(Time.now)
end
@ -100,7 +100,7 @@ class WikiControllerTest < Test::Unit::TestCase
test_renderer)
r = process 'edit', 'web' => 'wiki1', 'id' => 'With : Special /> symbols'
assert_success
assert_response(:success)
xml = REXML::Document.new(r.body)
form = REXML::XPath.first(xml, '//form')
assert_equal '/wiki1/save/With+%3A+Special+%2F%3E+symbols', form.attributes['action']
@ -111,7 +111,7 @@ class WikiControllerTest < Test::Unit::TestCase
@home.rollback(0, Time.now, 'Rick', test_renderer)
r = process 'export_html', 'web' => 'wiki1'
assert_success(bypass_body_parsing = true)
assert_response(:success, bypass_body_parsing = true)
assert_equal 'application/zip', r.headers['Content-Type']
assert_match /attachment; filename="wiki1-html-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/,
r.headers['Content-Disposition']
@ -139,7 +139,7 @@ class WikiControllerTest < Test::Unit::TestCase
def test_export_html_no_layout
r = process 'export_html', 'web' => 'wiki1', 'layout' => 'no'
assert_success(bypass_body_parsing = true)
assert_response(:success, bypass_body_parsing = true)
assert_equal 'application/zip', r.headers['Content-Type']
assert_match /attachment; filename="wiki1-html-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/,
r.headers['Content-Disposition']
@ -149,7 +149,7 @@ class WikiControllerTest < Test::Unit::TestCase
def test_export_markup
r = process 'export_markup', 'web' => 'wiki1'
assert_success(bypass_body_parsing = true)
assert_response(:success, bypass_body_parsing = true)
assert_equal 'application/zip', r.headers['Content-Type']
assert_match /attachment; filename="wiki1-textile-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/,
r.headers['Content-Disposition']
@ -161,7 +161,7 @@ class WikiControllerTest < Test::Unit::TestCase
def test_export_pdf
r = process 'export_pdf', 'web' => 'wiki1'
assert_success(bypass_body_parsing = true)
assert_response(:success, bypass_body_parsing = true)
assert_equal 'application/pdf', r.headers['Content-Type']
assert_match /attachment; filename="wiki1-tex-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.pdf"/,
r.headers['Content-Disposition']
@ -178,7 +178,7 @@ class WikiControllerTest < Test::Unit::TestCase
def test_export_tex
r = process 'export_tex', 'web' => 'wiki1'
assert_success(bypass_body_parsing = true)
assert_response(:success, bypass_body_parsing = true)
assert_equal 'application/octet-stream', r.headers['Content-Type']
assert_match /attachment; filename="wiki1-tex-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.tex"/,
r.headers['Content-Disposition']
@ -229,21 +229,21 @@ class WikiControllerTest < Test::Unit::TestCase
def test_locked
@home.lock(Time.now, 'Locky')
r = process('locked', 'web' => 'wiki1', 'id' => 'HomePage')
assert_success
assert_response(:success)
assert_equal @home, r.template_objects['page']
end
def test_login
r = process 'login', 'web' => 'wiki1'
assert_success
assert_response(:success)
# this action goes straight to the templates
end
def test_new
r = process('new', 'id' => 'NewPage', 'web' => 'wiki1')
assert_success
assert_response(:success)
assert_equal 'AnonymousCoward', r.template_objects['author']
assert_equal 'NewPage', r.template_objects['page_name']
end
@ -254,7 +254,7 @@ class WikiControllerTest < Test::Unit::TestCase
def test_pdf
assert RedClothForTex.available?, 'Cannot do test_pdf when pdflatex is not available'
r = process('pdf', 'web' => 'wiki1', 'id' => 'HomePage')
assert_success(bypass_body_parsing = true)
assert_response(:success, bypass_body_parsing = true)
assert_equal '%PDF', r.body[0..3]
assert_equal "EOF\n", r.body[-4..-1]
@ -270,7 +270,7 @@ class WikiControllerTest < Test::Unit::TestCase
def test_print
r = process('print', 'web' => 'wiki1', 'id' => 'HomePage')
assert_success
assert_response(:success)
assert_equal :show, r.template_objects['link_mode']
end
@ -280,7 +280,7 @@ class WikiControllerTest < Test::Unit::TestCase
r = process('published', 'web' => 'wiki1', 'id' => 'HomePage')
assert_success
assert_response(:success)
assert_equal @home, r.template_objects['page']
end
@ -298,14 +298,14 @@ class WikiControllerTest < Test::Unit::TestCase
r = process('published', 'web' => 'wiki1')
assert_success
assert_response(:success)
assert_equal @home, r.template_objects['page']
end
def test_recently_revised
r = process('recently_revised', 'web' => 'wiki1')
assert_success
assert_response(:success)
assert_equal %w(animals trees), r.template_objects['categories']
assert_nil r.template_objects['category']
@ -332,7 +332,7 @@ class WikiControllerTest < Test::Unit::TestCase
Time.now, Author.new('AnotherAuthor', '127.0.0.2'), test_renderer)
r = process('recently_revised', 'web' => 'wiki1')
assert_success
assert_response(:success)
assert_equal %w(animals categorized trees), r.template_objects['categories']
# no category is specified in params
@ -345,7 +345,7 @@ class WikiControllerTest < Test::Unit::TestCase
def test_recently_revised_with_categorized_page_multiple_categories
r = process('recently_revised', 'web' => 'wiki1')
assert_success
assert_response(:success)
assert_equal ['animals', 'trees'], r.template_objects['categories']
# no category is specified in params
@ -358,7 +358,7 @@ class WikiControllerTest < Test::Unit::TestCase
def test_recently_revised_with_specified_category
r = process('recently_revised', 'web' => 'wiki1', 'category' => 'animals')
assert_success
assert_response(:success)
assert_equal ['animals', 'trees'], r.template_objects['categories']
# no category is specified in params
@ -371,7 +371,7 @@ class WikiControllerTest < Test::Unit::TestCase
def test_revision
r = process 'revision', 'web' => 'wiki1', 'id' => 'HomePage', 'rev' => '1'
assert_success
assert_response(:success)
assert_equal @home, r.template_objects['page']
assert_equal @home.revisions[0], r.template_objects['revision']
end
@ -382,7 +382,7 @@ class WikiControllerTest < Test::Unit::TestCase
# its assigns the same as or revision
r = process 'rollback', 'web' => 'wiki1', 'id' => 'HomePage', 'rev' => '1'
assert_success
assert_response(:success)
assert_equal @home, r.template_objects['page']
assert_equal @home.revisions[0], r.template_objects['revision']
end
@ -390,7 +390,7 @@ class WikiControllerTest < Test::Unit::TestCase
def test_rss_with_content
r = process 'rss_with_content', 'web' => 'wiki1'
assert_success
assert_response(:success)
pages = r.template_objects['pages_by_revision']
assert_equal [@elephant, @oak, pages(:no_wiki_word), pages(:that_way), pages(:smart_engine), pages(:my_way), pages(:first_page), @home], pages,
"Pages are not as expected: #{pages.map {|p| p.name}.inspect}"
@ -416,7 +416,7 @@ class WikiControllerTest < Test::Unit::TestCase
r = process 'rss_with_headlines', 'web' => 'wiki1'
assert_success
assert_response(:success)
pages = r.template_objects['pages_by_revision']
assert_equal [@elephant, @title_with_spaces, @oak, pages(:no_wiki_word), pages(:that_way), pages(:smart_engine), pages(:my_way), pages(:first_page), @home], pages, "Pages are not as expected: #{pages.map {|p| p.name}.inspect}"
assert r.template_objects['hide_description']
@ -450,7 +450,7 @@ class WikiControllerTest < Test::Unit::TestCase
r = process 'rss_with_headlines', 'web' => 'wiki1'
assert_success
assert_response(:success)
xml = REXML::Document.new(r.body)
expected_page_links =
@ -473,37 +473,37 @@ class WikiControllerTest < Test::Unit::TestCase
setup_wiki_with_30_pages
r = process 'rss_with_headlines', 'web' => 'wiki1'
assert_success
assert_response(:success)
pages = r.template_objects['pages_by_revision']
assert_equal 15, pages.size, 15
r = process 'rss_with_headlines', 'web' => 'wiki1', 'limit' => '5'
assert_success
assert_response(:success)
pages = r.template_objects['pages_by_revision']
assert_equal 5, pages.size
r = process 'rss_with_headlines', 'web' => 'wiki1', 'limit' => '25'
assert_success
assert_response(:success)
pages = r.template_objects['pages_by_revision']
assert_equal 25, pages.size
r = process 'rss_with_headlines', 'web' => 'wiki1', 'limit' => 'all'
assert_success
assert_response(:success)
pages = r.template_objects['pages_by_revision']
assert_equal 38, pages.size
r = process 'rss_with_headlines', 'web' => 'wiki1', 'start' => '1976-10-16'
assert_success
assert_response(:success)
pages = r.template_objects['pages_by_revision']
assert_equal 23, pages.size
r = process 'rss_with_headlines', 'web' => 'wiki1', 'end' => '1976-10-16'
assert_success
assert_response(:success)
pages = r.template_objects['pages_by_revision']
assert_equal 15, pages.size
r = process 'rss_with_headlines', 'web' => 'wiki1', 'start' => '1976-10-01', 'end' => '1976-10-06'
assert_success
assert_response(:success)
pages = r.template_objects['pages_by_revision']
assert_equal 5, pages.size
end
@ -565,7 +565,7 @@ class WikiControllerTest < Test::Unit::TestCase
'author' => 'SomeOtherAuthor'}, {:return_to => '/wiki1/show/HomePage'}
assert_redirected_to :action => 'edit', :web => 'wiki1', :id => 'HomePage'
assert_flash_has :error
assert(@response.has_key(:error))
assert r.flash[:error].kind_of?(Instiki::ValidationError)
revisions_after = @home.revisions.size
@ -597,7 +597,7 @@ class WikiControllerTest < Test::Unit::TestCase
def test_search_multiple_results
r = process 'search', 'web' => 'wiki1', 'query' => 'All about'
assert_success
assert_response(:success)
assert_equal 'All about', r.template_objects['query']
assert_equal [@elephant, @oak], r.template_objects['results']
assert_equal [], r.template_objects['title_results']
@ -606,7 +606,7 @@ class WikiControllerTest < Test::Unit::TestCase
def test_search_by_content_and_title
r = process 'search', 'web' => 'wiki1', 'query' => '(Oak|Elephant)'
assert_success
assert_response(:success)
assert_equal '(Oak|Elephant)', r.template_objects['query']
assert_equal [@elephant, @oak], r.template_objects['results']
assert_equal [@elephant, @oak], r.template_objects['title_results']
@ -615,14 +615,14 @@ class WikiControllerTest < Test::Unit::TestCase
def test_search_zero_results
r = process 'search', 'web' => 'wiki1', 'query' => 'non-existant text'
assert_success
assert_response(:success)
assert_equal [], r.template_objects['results']
assert_equal [], r.template_objects['title_results']
end
def test_show_page
r = process('show', 'id' => 'Oak', 'web' => 'wiki1')
assert_success
assert_response(:success)
assert_tag :content => /All about oak/
end
@ -632,7 +632,7 @@ class WikiControllerTest < Test::Unit::TestCase
r = process('show', 'id' => 'HomePage', 'web' => 'wiki1')
assert_success
assert_response(:success)
assert_match /Second revision of the <a.*HomePage.*<\/a> end/, r.body
end
@ -651,7 +651,7 @@ class WikiControllerTest < Test::Unit::TestCase
def test_tex
r = process('tex', 'web' => 'wiki1', 'id' => 'HomePage')
assert_success
assert_response(:success)
assert_equal "\\documentclass[12pt,titlepage]{article}\n\n\\usepackage[danish]{babel} " +
"%danske tekster\n\\usepackage[OT1]{fontenc} %rigtige danske bogstaver...\n" +
@ -669,7 +669,7 @@ class WikiControllerTest < Test::Unit::TestCase
r = process('web_list')
assert_success
assert_response(:success)
assert_equal [another_wiki, webs(:instiki), @web], r.template_objects['webs']
end