Some Tests
Some functional tests for 'delete orphaned pages by category'.
This commit is contained in:
parent
3a78ef3dbf
commit
34fcd7943a
|
@ -118,7 +118,7 @@
|
|||
'accept-charset' => 'utf-8' }) do
|
||||
%>
|
||||
<p style="text-align:right;font-size:.85em;">
|
||||
Clean up this Web by entering the system password
|
||||
Clean up this web (<%= @web.name %>) by entering the system password
|
||||
<input type="password" id="system_password_orphaned" class="disableAutoComplete" name="system_password_orphaned" />
|
||||
and
|
||||
<input type="submit" value="Delete Orphan Pages" />
|
||||
|
@ -152,7 +152,7 @@
|
|||
'accept-charset' => 'utf-8' }) do
|
||||
%>
|
||||
<p style="text-align:right;">
|
||||
Delete this Web, and all its pages. Enter system password
|
||||
Delete this web (<%= @web.name %>), and all its pages. Enter system password
|
||||
<input type="password" id="system_password_delete_web" class="disableAutoComplete" name="system_password_delete_web" />
|
||||
and
|
||||
<input type="submit" value="Delete Web" />
|
||||
|
|
|
@ -226,6 +226,47 @@ class AdminControllerTest < Test::Unit::TestCase
|
|||
"Pages are not as expected: #{@web.select.sort.map {|p| p.name}.inspect}"
|
||||
end
|
||||
|
||||
def test_remove_orphaned_pages_in_category
|
||||
@wiki.system.update_attribute(:password, 'pswd')
|
||||
page_order = [pages(:elephant), pages(:first_page), @home, pages(:my_way), pages(:no_wiki_word), @oak, pages(:smart_engine), pages(:that_way)]
|
||||
orphan_page_linking_to_oak = @wiki.write_page('wiki1', 'Pine',
|
||||
"Refers to [[Oak]].\n" +
|
||||
"category: trees",
|
||||
Time.now, Author.new('TreeHugger', '127.0.0.2'), test_renderer)
|
||||
|
||||
r = process('remove_orphaned_pages_in_category', 'web' => 'wiki1', 'category' => 'trees','system_password_orphaned_in_category' => 'pswd')
|
||||
|
||||
assert_redirected_to :controller => 'wiki', :web => 'wiki1', :action => 'list'
|
||||
@web.pages(true)
|
||||
assert_equal page_order, @web.select.sort,
|
||||
"Pages are not as expected: #{@web.select.sort.map {|p| p.name}.inspect}"
|
||||
|
||||
# Oak is now orphan, but it's not in the 'animals' category,
|
||||
# so the second pass should not remove it
|
||||
r = process('remove_orphaned_pages_in_category', 'web' => 'wiki1', 'category' => 'animals', 'system_password_orphaned_in_category' => 'pswd')
|
||||
assert_redirected_to :controller => 'wiki', :web => 'wiki1', :action => 'list'
|
||||
@web.pages(true)
|
||||
page_order.delete(pages(:elephant))
|
||||
assert_equal page_order, @web.select.sort,
|
||||
"Pages are not as expected: #{@web.select.sort.map {|p| p.name}.inspect}"
|
||||
|
||||
# third pass does does nothing, since there are no pages in the
|
||||
# 'leaves' category.
|
||||
r = process('remove_orphaned_pages_in_category', 'web' => 'wiki1', 'category' => 'leaves', 'system_password_orphaned_in_category' => 'pswd')
|
||||
assert_redirected_to :action => 'list'
|
||||
@web.pages(true)
|
||||
assert_equal page_order, @web.select.sort,
|
||||
"Pages are not as expected: #{@web.select.sort.map {|p| p.name}.inspect}"
|
||||
|
||||
# fourth pass destroys Oak
|
||||
r = process('remove_orphaned_pages_in_category', 'web' => 'wiki1', 'category' => 'trees', 'system_password_orphaned_in_category' => 'pswd')
|
||||
assert_redirected_to :action => 'list'
|
||||
@web.pages(true)
|
||||
page_order.delete(@oak)
|
||||
assert_equal page_order, @web.select.sort,
|
||||
"Pages are not as expected: #{@web.select.sort.map {|p| p.name}.inspect}"
|
||||
end
|
||||
|
||||
def test_remove_orphaned_pages_empty_or_wrong_password
|
||||
@wiki.system[:password] = 'pswd'
|
||||
|
||||
|
|
|
@ -30,4 +30,10 @@ class NoWikiTest < Test::Unit::TestCase
|
|||
)
|
||||
end
|
||||
|
||||
def test_sanitize_nowiki_ill_formed_II
|
||||
match(NoWiki, "<nowiki><animateColor xlink:href='#foo'/>\000</nowiki>",
|
||||
:plain_text => %(<animateColor xlink:href='#foo'></animateColor>\xEF\xBF\xBD)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue