Moved remove_orphaned_pages action to admin controller
This commit is contained in:
parent
bb2d16c8a1
commit
112a21da5c
6 changed files with 43 additions and 40 deletions
|
@ -76,4 +76,15 @@ class AdminController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def remove_orphaned_pages
|
||||
if wiki.authenticate(@params['system_password_orphaned'])
|
||||
wiki.remove_orphaned_pages(@web_name)
|
||||
flash[:info] = 'Orphaned pages removed'
|
||||
redirect_to :action => 'list'
|
||||
else
|
||||
flash[:error] = password_error(@params['system_password'])
|
||||
return_to_last_remembered
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -88,17 +88,6 @@ class WikiController < ApplicationController
|
|||
@pages_by_revision = @pages_in_category.by_revision
|
||||
end
|
||||
|
||||
def remove_orphaned_pages
|
||||
if wiki.authenticate(@params['system_password_orphaned'])
|
||||
wiki.remove_orphaned_pages(@web_name)
|
||||
flash[:info] = 'Orphaned pages removed'
|
||||
redirect_to :action => 'list'
|
||||
else
|
||||
flash[:error] = password_error(@params['system_password'])
|
||||
return_to_last_remembered
|
||||
end
|
||||
end
|
||||
|
||||
def rss_with_content
|
||||
render_rss
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<% @title = "Edit Web" %>
|
||||
|
||||
<p><%= @wiki.system[:password] %></p>
|
||||
|
||||
<form action="edit_web" id="setup" method="post"
|
||||
onSubmit="cleanAddress(); return validateEditWebForm()">
|
||||
<h2 style="margin-bottom: 3px">Name and address</h2>
|
||||
|
|
|
@ -65,6 +65,7 @@ class DispatchServlet
|
|||
'create_system' => 'admin',
|
||||
'create_web' => 'admin',
|
||||
'edit_web' => 'admin',
|
||||
'remove_orphaned_pages' => 'admin',
|
||||
'file' => 'file',
|
||||
'import' => 'file',
|
||||
'pic' => 'file',
|
||||
|
|
|
@ -189,4 +189,33 @@ class AdminControllerTest < Test::Unit::TestCase
|
|||
assert_flash_has :error
|
||||
end
|
||||
|
||||
|
||||
def test_remove_orphaned_pages
|
||||
setup_wiki_with_three_pages
|
||||
@wiki.system[:password] = 'pswd'
|
||||
orhan_page_linking_to_oak = @wiki.write_page('wiki1', 'Pine',
|
||||
"Refers to [[Oak]].\n" +
|
||||
"category: trees",
|
||||
Time.now, Author.new('TreeHugger', '127.0.0.2'))
|
||||
|
||||
r = process('remove_orphaned_pages', 'web' => 'wiki1', 'system_password_orphaned' => 'pswd')
|
||||
|
||||
assert_redirected_to :action => 'list'
|
||||
assert_equal [@home, @oak], @web.select.sort,
|
||||
"Pages are not as expected: #{@web.select.sort.map {|p| p.name}.inspect}"
|
||||
|
||||
|
||||
# Oak is now orphan, second pass should remove it
|
||||
r = process('remove_orphaned_pages', 'web' => 'wiki1', 'system_password' => 'pswd')
|
||||
assert_redirected_to :action => 'list'
|
||||
assert_equal [@home], @web.select.sort,
|
||||
"Pages are not as expected: #{@web.select.sort.map {|p| p.name}.inspect}"
|
||||
|
||||
# third pass does not destroy HomePage
|
||||
r = process('remove_orphaned_pages', 'web' => 'wiki1', 'system_password' => 'pswd')
|
||||
assert_redirected_to :action => 'list'
|
||||
assert_equal [@home], @web.select.sort,
|
||||
"Pages are not as expected: #{@web.select.sort.map {|p| p.name}.inspect}"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -325,35 +325,6 @@ class WikiControllerTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
|
||||
def test_remove_orphaned_pages
|
||||
setup_wiki_with_three_pages
|
||||
@wiki.system[:password] = 'pswd'
|
||||
orhan_page_linking_to_oak = @wiki.write_page('wiki1', 'Pine',
|
||||
"Refers to [[Oak]].\n" +
|
||||
"category: trees",
|
||||
Time.now, Author.new('TreeHugger', '127.0.0.2'))
|
||||
|
||||
r = process('remove_orphaned_pages', 'web' => 'wiki1', 'system_password_orphaned' => 'pswd')
|
||||
|
||||
assert_redirected_to :action => 'list'
|
||||
assert_equal [@home, @oak], @web.select.sort,
|
||||
"Pages are not as expected: #{@web.select.sort.map {|p| p.name}.inspect}"
|
||||
|
||||
|
||||
# Oak is now orphan, second pass should remove it
|
||||
r = process('remove_orphaned_pages', 'web' => 'wiki1', 'system_password' => 'pswd')
|
||||
assert_redirected_to :action => 'list'
|
||||
assert_equal [@home], @web.select.sort,
|
||||
"Pages are not as expected: #{@web.select.sort.map {|p| p.name}.inspect}"
|
||||
|
||||
# third pass does not destroy HomePage
|
||||
r = process('remove_orphaned_pages', 'web' => 'wiki1', 'system_password' => 'pswd')
|
||||
assert_redirected_to :action => 'list'
|
||||
assert_equal [@home], @web.select.sort,
|
||||
"Pages are not as expected: #{@web.select.sort.map {|p| p.name}.inspect}"
|
||||
end
|
||||
|
||||
|
||||
def test_revision
|
||||
r = process 'revision', 'web' => 'wiki1', 'id' => 'HomePage', 'rev' => '0'
|
||||
|
||||
|
|
Loading…
Reference in a new issue