Fixed functional tests
This commit is contained in:
parent
7aaa35ae4a
commit
829d54a368
3 changed files with 63 additions and 72 deletions
|
@ -27,7 +27,7 @@ class FileControllerTest < Test::Unit::TestCase
|
||||||
def test_file
|
def test_file
|
||||||
process 'file', 'web' => 'wiki1', 'id' => 'foo.tgz'
|
process 'file', 'web' => 'wiki1', 'id' => 'foo.tgz'
|
||||||
|
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_rendered_file 'file/file'
|
assert_rendered_file 'file/file'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ class FileControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
r = process 'file', 'web' => 'wiki1', 'id' => 'foo.txt'
|
r = process 'file', 'web' => 'wiki1', 'id' => 'foo.txt'
|
||||||
|
|
||||||
assert_response :success
|
assert_success(bypass_body_parsing = true)
|
||||||
assert_equal "aaa\nbbb\n", r.binary_content
|
assert_equal "aaa\nbbb\n", r.body
|
||||||
assert_equal 'text/plain', r.headers['Content-Type']
|
assert_equal 'text/plain', r.headers['Content-Type']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ class FileControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
r = process 'file', 'web' => 'wiki1', 'id' => 'foo.pdf'
|
r = process 'file', 'web' => 'wiki1', 'id' => 'foo.pdf'
|
||||||
|
|
||||||
assert_response :success
|
assert_success(bypass_body_parsing = true)
|
||||||
assert_equal "aaa\nbbb\n", r.binary_content
|
assert_equal "aaa\nbbb\n", r.body
|
||||||
assert_equal 'application/pdf', r.headers['Content-Type']
|
assert_equal 'application/pdf', r.headers['Content-Type']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -56,14 +56,14 @@ class FileControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
r = process 'pic', 'web' => 'wiki1', 'id' => 'rails.gif'
|
r = process 'pic', 'web' => 'wiki1', 'id' => 'rails.gif'
|
||||||
|
|
||||||
assert_response :success
|
assert_success(bypass_body_parsing = true)
|
||||||
assert_equal File.size("#{FILE_AREA}/rails.gif"), r.binary_content.size
|
assert_equal File.size("#{FILE_AREA}/rails.gif"), r.body.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_pic_unknown_pic
|
def test_pic_unknown_pic
|
||||||
r = process 'pic', 'web' => 'wiki1', 'id' => 'non-existant.gif'
|
r = process 'pic', 'web' => 'wiki1', 'id' => 'non-existant.gif'
|
||||||
|
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_rendered_file 'file/file'
|
assert_rendered_file 'file/file'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class FileControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
# rails-e2e.gif is unknown to the system, so pic action goes to the file [upload] form
|
# 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'
|
r = process 'pic', 'web' => 'wiki1', 'id' => 'rails-e2e.gif'
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_rendered_file 'file/file'
|
assert_rendered_file 'file/file'
|
||||||
|
|
||||||
# User uploads the picture
|
# User uploads the picture
|
||||||
|
@ -100,7 +100,7 @@ class FileControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
# rails-e2e.gif is unknown to the system, so pic action goes to the file [upload] form
|
# rails-e2e.gif is unknown to the system, so pic action goes to the file [upload] form
|
||||||
r = process 'file', 'web' => 'wiki1', 'id' => 'instiki-e2e.txt'
|
r = process 'file', 'web' => 'wiki1', 'id' => 'instiki-e2e.txt'
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_rendered_file 'file/file'
|
assert_rendered_file 'file/file'
|
||||||
|
|
||||||
# User uploads the picture
|
# User uploads the picture
|
||||||
|
@ -120,7 +120,7 @@ class FileControllerTest < Test::Unit::TestCase
|
||||||
def test_uploads_blocking
|
def test_uploads_blocking
|
||||||
set_web_property :allow_uploads, true
|
set_web_property :allow_uploads, true
|
||||||
r = process 'file', 'web' => 'wiki1', 'id' => 'filename'
|
r = process 'file', 'web' => 'wiki1', 'id' => 'filename'
|
||||||
assert_response :success
|
assert_success
|
||||||
|
|
||||||
set_web_property :allow_uploads, false
|
set_web_property :allow_uploads, false
|
||||||
r = process 'file', 'web' => 'wiki1', 'id' => 'filename'
|
r = process 'file', 'web' => 'wiki1', 'id' => 'filename'
|
||||||
|
|
|
@ -50,7 +50,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
r = process('authors', 'web' => 'wiki1')
|
r = process('authors', 'web' => 'wiki1')
|
||||||
|
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_equal %w(AnAuthor BreakingTheOrder DavidHeinemeierHansson Guest Me TreeHugger),
|
assert_equal %w(AnAuthor BreakingTheOrder DavidHeinemeierHansson Guest Me TreeHugger),
|
||||||
r.template_objects['authors']
|
r.template_objects['authors']
|
||||||
end
|
end
|
||||||
|
@ -67,7 +67,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_edit
|
def test_edit
|
||||||
r = process 'edit', 'web' => 'wiki1', 'id' => 'HomePage'
|
r = process 'edit', 'web' => 'wiki1', 'id' => 'HomePage'
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_equal @wiki.read_page('wiki1', 'HomePage'), r.template_objects['page']
|
assert_equal @wiki.read_page('wiki1', 'HomePage'), r.template_objects['page']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
def test_edit_page_break_lock
|
def test_edit_page_break_lock
|
||||||
@home.lock(Time.now, 'Locky')
|
@home.lock(Time.now, 'Locky')
|
||||||
process 'edit', 'web' => 'wiki1', 'id' => 'HomePage', 'break_lock' => 'y'
|
process 'edit', 'web' => 'wiki1', 'id' => 'HomePage', 'break_lock' => 'y'
|
||||||
assert_response :success
|
assert_success
|
||||||
@home = Page.find(@home.id)
|
@home = Page.find(@home.id)
|
||||||
assert @home.locked?(Time.now)
|
assert @home.locked?(Time.now)
|
||||||
end
|
end
|
||||||
|
@ -97,7 +97,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
Time.now, Author.new('Special', '127.0.0.3'))
|
Time.now, Author.new('Special', '127.0.0.3'))
|
||||||
|
|
||||||
r = process 'edit', 'web' => 'wiki1', 'id' => 'With : Special /> symbols'
|
r = process 'edit', 'web' => 'wiki1', 'id' => 'With : Special /> symbols'
|
||||||
assert_response :success
|
assert_success
|
||||||
xml = REXML::Document.new(r.body)
|
xml = REXML::Document.new(r.body)
|
||||||
form = REXML::XPath.first(xml, '//form')
|
form = REXML::XPath.first(xml, '//form')
|
||||||
assert_equal '/wiki1/save/With+%3A+Special+%2F%3E+symbols', form.attributes['action']
|
assert_equal '/wiki1/save/With+%3A+Special+%2F%3E+symbols', form.attributes['action']
|
||||||
|
@ -107,18 +107,17 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
@home.rollback(0, Time.now, 'Rick') # much simpler regex statement to match
|
@home.rollback(0, Time.now, 'Rick') # much simpler regex statement to match
|
||||||
r = process 'export_html', 'web' => 'wiki1'
|
r = process 'export_html', 'web' => 'wiki1'
|
||||||
|
|
||||||
assert_response :success
|
assert_success(bypass_body_parsing = true)
|
||||||
assert_equal 'application/zip', r.headers['Content-Type']
|
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"/,
|
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']
|
r.headers['Content-Disposition']
|
||||||
content = r.binary_content
|
assert_equal 'PK', r.body[0..1], 'Content is not a zip file'
|
||||||
assert_equal 'PK', content[0..1], 'Content is not a zip file'
|
|
||||||
assert_equal :export, r.template_objects['link_mode']
|
assert_equal :export, r.template_objects['link_mode']
|
||||||
|
|
||||||
# Tempfile doesn't know how to open files with binary flag, hence the two-step process
|
# Tempfile doesn't know how to open files with binary flag, hence the two-step process
|
||||||
Tempfile.open('instiki_export_file') { |f| @tempfile_path = f.path }
|
Tempfile.open('instiki_export_file') { |f| @tempfile_path = f.path }
|
||||||
begin
|
begin
|
||||||
File.open(@tempfile_path, 'wb') { |f| f.write(content); @exported_file = f.path }
|
File.open(@tempfile_path, 'wb') { |f| f.write(r.body); @exported_file = f.path }
|
||||||
Zip::ZipFile.open(@exported_file) do |zip|
|
Zip::ZipFile.open(@exported_file) do |zip|
|
||||||
assert_equal %w(Elephant.html FirstPage.html HomePage.html MyWay.html NoWikiWord.html Oak.html SmartEngine.html ThatWay.html index.html), zip.dir.entries('.').sort
|
assert_equal %w(Elephant.html FirstPage.html HomePage.html MyWay.html NoWikiWord.html Oak.html SmartEngine.html ThatWay.html index.html), zip.dir.entries('.').sort
|
||||||
assert_match /.*<html .*All about elephants.*<\/html>/,
|
assert_match /.*<html .*All about elephants.*<\/html>/,
|
||||||
|
@ -137,24 +136,22 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
def test_export_html_no_layout
|
def test_export_html_no_layout
|
||||||
r = process 'export_html', 'web' => 'wiki1', 'layout' => 'no'
|
r = process 'export_html', 'web' => 'wiki1', 'layout' => 'no'
|
||||||
|
|
||||||
assert_response :success
|
assert_success(bypass_body_parsing = true)
|
||||||
assert_equal 'application/zip', r.headers['Content-Type']
|
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"/,
|
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']
|
r.headers['Content-Disposition']
|
||||||
content = r.binary_content
|
assert_equal 'PK', r.body[0..1], 'Content is not a zip file'
|
||||||
assert_equal 'PK', content[0..1], 'Content is not a zip file'
|
|
||||||
assert_equal :export, r.template_objects['link_mode']
|
assert_equal :export, r.template_objects['link_mode']
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_export_markup
|
def test_export_markup
|
||||||
r = process 'export_markup', 'web' => 'wiki1'
|
r = process 'export_markup', 'web' => 'wiki1'
|
||||||
|
|
||||||
assert_response :success
|
assert_success(bypass_body_parsing = true)
|
||||||
assert_equal 'application/zip', r.headers['Content-Type']
|
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"/,
|
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']
|
r.headers['Content-Disposition']
|
||||||
content = r.binary_content
|
assert_equal 'PK', r.body[0..1], 'Content is not a zip file'
|
||||||
assert_equal 'PK', content[0..1], 'Content is not a zip file'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,13 +159,12 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_export_pdf
|
def test_export_pdf
|
||||||
r = process 'export_pdf', 'web' => 'wiki1'
|
r = process 'export_pdf', 'web' => 'wiki1'
|
||||||
assert_response :success
|
assert_success(bypass_body_parsing = true)
|
||||||
assert_equal 'application/pdf', r.headers['Content-Type']
|
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"/,
|
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']
|
r.headers['Content-Disposition']
|
||||||
content = r.binary_content
|
assert_equal '%PDF', r.body[0..3]
|
||||||
assert_equal '%PDF', content[0..3]
|
assert_equal "EOF\n", r.body[-4..-1]
|
||||||
assert_equal "EOF\n", content[-4..-1]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -180,12 +176,11 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
def test_export_tex
|
def test_export_tex
|
||||||
r = process 'export_tex', 'web' => 'wiki1'
|
r = process 'export_tex', 'web' => 'wiki1'
|
||||||
|
|
||||||
assert_response :success
|
assert_success(bypass_body_parsing = true)
|
||||||
assert_equal 'application/octet-stream', r.headers['Content-Type']
|
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"/,
|
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']
|
r.headers['Content-Disposition']
|
||||||
content = r.binary_content
|
assert_equal '\documentclass', r.body[0..13], 'Content is not a TeX file'
|
||||||
assert_equal '\documentclass', content[0..13], 'Content is not a TeX file'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_feeds
|
def test_feeds
|
||||||
|
@ -230,21 +225,21 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
def test_locked
|
def test_locked
|
||||||
@home.lock(Time.now, 'Locky')
|
@home.lock(Time.now, 'Locky')
|
||||||
r = process('locked', 'web' => 'wiki1', 'id' => 'HomePage')
|
r = process('locked', 'web' => 'wiki1', 'id' => 'HomePage')
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_equal @home, r.template_objects['page']
|
assert_equal @home, r.template_objects['page']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def test_login
|
def test_login
|
||||||
r = process 'login', 'web' => 'wiki1'
|
r = process 'login', 'web' => 'wiki1'
|
||||||
assert_response :success
|
assert_success
|
||||||
# this action goes straight to the templates
|
# this action goes straight to the templates
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def test_new
|
def test_new
|
||||||
r = process('new', 'id' => 'NewPage', 'web' => 'wiki1')
|
r = process('new', 'id' => 'NewPage', 'web' => 'wiki1')
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_equal 'AnonymousCoward', r.template_objects['author']
|
assert_equal 'AnonymousCoward', r.template_objects['author']
|
||||||
assert_equal 'NewPage', r.template_objects['page_name']
|
assert_equal 'NewPage', r.template_objects['page_name']
|
||||||
end
|
end
|
||||||
|
@ -255,12 +250,10 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
def test_pdf
|
def test_pdf
|
||||||
assert RedClothForTex.available?, 'Cannot do test_pdf when pdflatex is not available'
|
assert RedClothForTex.available?, 'Cannot do test_pdf when pdflatex is not available'
|
||||||
r = process('pdf', 'web' => 'wiki1', 'id' => 'HomePage')
|
r = process('pdf', 'web' => 'wiki1', 'id' => 'HomePage')
|
||||||
assert_response :success
|
assert_success(bypass_body_parsing = true)
|
||||||
|
|
||||||
content = r.binary_content
|
assert_equal '%PDF', r.body[0..3]
|
||||||
|
assert_equal "EOF\n", r.body[-4..-1]
|
||||||
assert_equal '%PDF', content[0..3]
|
|
||||||
assert_equal "EOF\n", content[-4..-1]
|
|
||||||
|
|
||||||
assert_equal 'application/pdf', r.headers['Content-Type']
|
assert_equal 'application/pdf', r.headers['Content-Type']
|
||||||
assert_match /attachment; filename="HomePage-wiki1-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.pdf"/,
|
assert_match /attachment; filename="HomePage-wiki1-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.pdf"/,
|
||||||
|
@ -273,7 +266,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
def test_print
|
def test_print
|
||||||
r = process('print', 'web' => 'wiki1', 'id' => 'HomePage')
|
r = process('print', 'web' => 'wiki1', 'id' => 'HomePage')
|
||||||
|
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_equal :show, r.template_objects['link_mode']
|
assert_equal :show, r.template_objects['link_mode']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -283,7 +276,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
r = process('published', 'web' => 'wiki1', 'id' => 'HomePage')
|
r = process('published', 'web' => 'wiki1', 'id' => 'HomePage')
|
||||||
|
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_equal @home, r.template_objects['page']
|
assert_equal @home, r.template_objects['page']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -299,7 +292,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_recently_revised
|
def test_recently_revised
|
||||||
r = process('recently_revised', 'web' => 'wiki1')
|
r = process('recently_revised', 'web' => 'wiki1')
|
||||||
assert_response :success
|
assert_success
|
||||||
|
|
||||||
assert_equal %w(animals trees), r.template_objects['categories']
|
assert_equal %w(animals trees), r.template_objects['categories']
|
||||||
assert_nil r.template_objects['category']
|
assert_nil r.template_objects['category']
|
||||||
|
@ -314,7 +307,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
Time.now, Author.new('AnotherAuthor', '127.0.0.2'))
|
Time.now, Author.new('AnotherAuthor', '127.0.0.2'))
|
||||||
|
|
||||||
r = process('recently_revised', 'web' => 'wiki1')
|
r = process('recently_revised', 'web' => 'wiki1')
|
||||||
assert_response :success
|
assert_success
|
||||||
|
|
||||||
assert_equal %w(animals categorized trees), r.template_objects['categories']
|
assert_equal %w(animals categorized trees), r.template_objects['categories']
|
||||||
# no category is specified in params
|
# no category is specified in params
|
||||||
|
@ -327,7 +320,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_recently_revised_with_categorized_page_multiple_categories
|
def test_recently_revised_with_categorized_page_multiple_categories
|
||||||
r = process('recently_revised', 'web' => 'wiki1')
|
r = process('recently_revised', 'web' => 'wiki1')
|
||||||
assert_response :success
|
assert_success
|
||||||
|
|
||||||
assert_equal ['animals', 'trees'], r.template_objects['categories']
|
assert_equal ['animals', 'trees'], r.template_objects['categories']
|
||||||
# no category is specified in params
|
# no category is specified in params
|
||||||
|
@ -340,7 +333,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_recently_revised_with_specified_category
|
def test_recently_revised_with_specified_category
|
||||||
r = process('recently_revised', 'web' => 'wiki1', 'category' => 'animals')
|
r = process('recently_revised', 'web' => 'wiki1', 'category' => 'animals')
|
||||||
assert_response :success
|
assert_success
|
||||||
|
|
||||||
assert_equal ['animals', 'trees'], r.template_objects['categories']
|
assert_equal ['animals', 'trees'], r.template_objects['categories']
|
||||||
# no category is specified in params
|
# no category is specified in params
|
||||||
|
@ -353,7 +346,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
def test_revision
|
def test_revision
|
||||||
r = process 'revision', 'web' => 'wiki1', 'id' => 'HomePage', 'rev' => '0'
|
r = process 'revision', 'web' => 'wiki1', 'id' => 'HomePage', 'rev' => '0'
|
||||||
|
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_equal @home, r.template_objects['page']
|
assert_equal @home, r.template_objects['page']
|
||||||
assert_equal @home.revisions[0], r.template_objects['revision']
|
assert_equal @home.revisions[0], r.template_objects['revision']
|
||||||
end
|
end
|
||||||
|
@ -364,7 +357,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
# its assigns the same as or revision
|
# its assigns the same as or revision
|
||||||
r = process 'rollback', 'web' => 'wiki1', 'id' => 'HomePage', 'rev' => '0'
|
r = process 'rollback', 'web' => 'wiki1', 'id' => 'HomePage', 'rev' => '0'
|
||||||
|
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_equal @home, r.template_objects['page']
|
assert_equal @home, r.template_objects['page']
|
||||||
assert_equal @home.revisions[0], r.template_objects['revision']
|
assert_equal @home.revisions[0], r.template_objects['revision']
|
||||||
end
|
end
|
||||||
|
@ -372,7 +365,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
def test_rss_with_content
|
def test_rss_with_content
|
||||||
r = process 'rss_with_content', 'web' => 'wiki1'
|
r = process 'rss_with_content', 'web' => 'wiki1'
|
||||||
|
|
||||||
assert_response :success
|
assert_success
|
||||||
pages = r.template_objects['pages_by_revision']
|
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,
|
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}"
|
"Pages are not as expected: #{pages.map {|p| p.name}.inspect}"
|
||||||
|
@ -398,7 +391,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
r = process 'rss_with_headlines', 'web' => 'wiki1'
|
r = process 'rss_with_headlines', 'web' => 'wiki1'
|
||||||
|
|
||||||
assert_response :success
|
assert_success
|
||||||
pages = r.template_objects['pages_by_revision']
|
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_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']
|
assert r.template_objects['hide_description']
|
||||||
|
@ -432,7 +425,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
r = process 'rss_with_headlines', 'web' => 'wiki1'
|
r = process 'rss_with_headlines', 'web' => 'wiki1'
|
||||||
|
|
||||||
assert_response :success
|
assert_success
|
||||||
xml = REXML::Document.new(r.body)
|
xml = REXML::Document.new(r.body)
|
||||||
|
|
||||||
expected_page_links =
|
expected_page_links =
|
||||||
|
@ -455,37 +448,37 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
setup_wiki_with_30_pages
|
setup_wiki_with_30_pages
|
||||||
|
|
||||||
r = process 'rss_with_headlines', 'web' => 'wiki1'
|
r = process 'rss_with_headlines', 'web' => 'wiki1'
|
||||||
assert_response :success
|
assert_success
|
||||||
pages = r.template_objects['pages_by_revision']
|
pages = r.template_objects['pages_by_revision']
|
||||||
assert_equal 15, pages.size, 15
|
assert_equal 15, pages.size, 15
|
||||||
|
|
||||||
r = process 'rss_with_headlines', 'web' => 'wiki1', 'limit' => '5'
|
r = process 'rss_with_headlines', 'web' => 'wiki1', 'limit' => '5'
|
||||||
assert_response :success
|
assert_success
|
||||||
pages = r.template_objects['pages_by_revision']
|
pages = r.template_objects['pages_by_revision']
|
||||||
assert_equal 5, pages.size
|
assert_equal 5, pages.size
|
||||||
|
|
||||||
r = process 'rss_with_headlines', 'web' => 'wiki1', 'limit' => '25'
|
r = process 'rss_with_headlines', 'web' => 'wiki1', 'limit' => '25'
|
||||||
assert_response :success
|
assert_success
|
||||||
pages = r.template_objects['pages_by_revision']
|
pages = r.template_objects['pages_by_revision']
|
||||||
assert_equal 25, pages.size
|
assert_equal 25, pages.size
|
||||||
|
|
||||||
r = process 'rss_with_headlines', 'web' => 'wiki1', 'limit' => 'all'
|
r = process 'rss_with_headlines', 'web' => 'wiki1', 'limit' => 'all'
|
||||||
assert_response :success
|
assert_success
|
||||||
pages = r.template_objects['pages_by_revision']
|
pages = r.template_objects['pages_by_revision']
|
||||||
assert_equal 38, pages.size
|
assert_equal 38, pages.size
|
||||||
|
|
||||||
r = process 'rss_with_headlines', 'web' => 'wiki1', 'start' => '1976-10-16'
|
r = process 'rss_with_headlines', 'web' => 'wiki1', 'start' => '1976-10-16'
|
||||||
assert_response :success
|
assert_success
|
||||||
pages = r.template_objects['pages_by_revision']
|
pages = r.template_objects['pages_by_revision']
|
||||||
assert_equal 23, pages.size
|
assert_equal 23, pages.size
|
||||||
|
|
||||||
r = process 'rss_with_headlines', 'web' => 'wiki1', 'end' => '1976-10-16'
|
r = process 'rss_with_headlines', 'web' => 'wiki1', 'end' => '1976-10-16'
|
||||||
assert_response :success
|
assert_success
|
||||||
pages = r.template_objects['pages_by_revision']
|
pages = r.template_objects['pages_by_revision']
|
||||||
assert_equal 15, pages.size
|
assert_equal 15, pages.size
|
||||||
|
|
||||||
r = process 'rss_with_headlines', 'web' => 'wiki1', 'start' => '1976-10-01', 'end' => '1976-10-06'
|
r = process 'rss_with_headlines', 'web' => 'wiki1', 'start' => '1976-10-01', 'end' => '1976-10-06'
|
||||||
assert_response :success
|
assert_success
|
||||||
pages = r.template_objects['pages_by_revision']
|
pages = r.template_objects['pages_by_revision']
|
||||||
assert_equal 5, pages.size
|
assert_equal 5, pages.size
|
||||||
end
|
end
|
||||||
|
@ -564,7 +557,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
def test_search_multiple_results
|
def test_search_multiple_results
|
||||||
r = process 'search', 'web' => 'wiki1', 'query' => 'All about'
|
r = process 'search', 'web' => 'wiki1', 'query' => 'All about'
|
||||||
|
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_equal 'All about', r.template_objects['query']
|
assert_equal 'All about', r.template_objects['query']
|
||||||
assert_equal [@elephant, @oak], r.template_objects['results']
|
assert_equal [@elephant, @oak], r.template_objects['results']
|
||||||
assert_equal [], r.template_objects['title_results']
|
assert_equal [], r.template_objects['title_results']
|
||||||
|
@ -573,7 +566,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
def test_search_by_content_and_title
|
def test_search_by_content_and_title
|
||||||
r = process 'search', 'web' => 'wiki1', 'query' => '(Oak|Elephant)'
|
r = process 'search', 'web' => 'wiki1', 'query' => '(Oak|Elephant)'
|
||||||
|
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_equal '(Oak|Elephant)', r.template_objects['query']
|
assert_equal '(Oak|Elephant)', r.template_objects['query']
|
||||||
assert_equal [@elephant, @oak], r.template_objects['results']
|
assert_equal [@elephant, @oak], r.template_objects['results']
|
||||||
assert_equal [@elephant, @oak], r.template_objects['title_results']
|
assert_equal [@elephant, @oak], r.template_objects['title_results']
|
||||||
|
@ -582,14 +575,14 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
def test_search_zero_results
|
def test_search_zero_results
|
||||||
r = process 'search', 'web' => 'wiki1', 'query' => 'non-existant text'
|
r = process 'search', 'web' => 'wiki1', 'query' => 'non-existant text'
|
||||||
|
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_equal [], r.template_objects['results']
|
assert_equal [], r.template_objects['results']
|
||||||
assert_equal [], r.template_objects['title_results']
|
assert_equal [], r.template_objects['title_results']
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_page
|
def test_show_page
|
||||||
r = process('show', 'id' => 'Oak', 'web' => 'wiki1')
|
r = process('show', 'id' => 'Oak', 'web' => 'wiki1')
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_tag :content => /All about oak/
|
assert_tag :content => /All about oak/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -599,7 +592,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
r = process('show', 'id' => 'HomePage', 'web' => 'wiki1')
|
r = process('show', 'id' => 'HomePage', 'web' => 'wiki1')
|
||||||
|
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_match /Second revision of the <a.*HomePage.*<\/a> end/, r.body
|
assert_match /Second revision of the <a.*HomePage.*<\/a> end/, r.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -619,7 +612,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_tex
|
def test_tex
|
||||||
r = process('tex', 'web' => 'wiki1', 'id' => 'HomePage')
|
r = process('tex', 'web' => 'wiki1', 'id' => 'HomePage')
|
||||||
assert_response :success
|
assert_success
|
||||||
|
|
||||||
assert_equal "\\documentclass[12pt,titlepage]{article}\n\n\\usepackage[danish]{babel} " +
|
assert_equal "\\documentclass[12pt,titlepage]{article}\n\n\\usepackage[danish]{babel} " +
|
||||||
"%danske tekster\n\\usepackage[OT1]{fontenc} %rigtige danske bogstaver...\n" +
|
"%danske tekster\n\\usepackage[OT1]{fontenc} %rigtige danske bogstaver...\n" +
|
||||||
|
@ -637,7 +630,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
r = process('web_list')
|
r = process('web_list')
|
||||||
|
|
||||||
assert_response :success
|
assert_success
|
||||||
assert_equal [another_wiki, webs(:instiki), @web], r.template_objects['webs']
|
assert_equal [another_wiki, webs(:instiki), @web], r.template_objects['webs']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -92,13 +92,11 @@ if defined? $validate_xml_in_assert_success and $validate_xml_in_assert_success
|
||||||
module Test
|
module Test
|
||||||
module Unit
|
module Unit
|
||||||
module Assertions
|
module Assertions
|
||||||
unless method_defined? :__assert_success_before_override_by_instiki
|
def assert_success(bypass_body_parsing = false)
|
||||||
alias :__assert_success_before_override_by_instiki :assert_success
|
assert_response :success
|
||||||
end
|
unless bypass_body_parsing
|
||||||
def assert_success
|
assert_nothing_raised(@response.body) { REXML::Document.new(@response.body) }
|
||||||
__assert_success_before_override_by_instiki
|
end
|
||||||
if @response.body.kind_of?(Proc) then # it's a file download, not an HTML content
|
|
||||||
else assert_nothing_raised(@response.body) { REXML::Document.new(@response.body) } end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue