From 112a21da5cce9d0b5f70a5b8f37dd5852c78e18f Mon Sep 17 00:00:00 2001 From: Alexey Verkhovsky Date: Sun, 13 Feb 2005 14:58:03 +0000 Subject: [PATCH] Moved remove_orphaned_pages action to admin controller --- app/controllers/admin_controller.rb | 11 +++++++++ app/controllers/wiki_controller.rb | 11 --------- app/views/admin/edit_web.rhtml | 2 ++ libraries/url_rewriting_hack.rb | 1 + test/functional/admin_controller_test.rb | 29 ++++++++++++++++++++++++ test/functional/wiki_controller_test.rb | 29 ------------------------ 6 files changed, 43 insertions(+), 40 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 969de977..8b970e02 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -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 diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 9c221329..65098210 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -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 diff --git a/app/views/admin/edit_web.rhtml b/app/views/admin/edit_web.rhtml index 468c4310..6b4e0a5f 100644 --- a/app/views/admin/edit_web.rhtml +++ b/app/views/admin/edit_web.rhtml @@ -1,5 +1,7 @@ <% @title = "Edit Web" %> +

<%= @wiki.system[:password] %>

+

Name and address

diff --git a/libraries/url_rewriting_hack.rb b/libraries/url_rewriting_hack.rb index 9017d7d2..371dc9ef 100644 --- a/libraries/url_rewriting_hack.rb +++ b/libraries/url_rewriting_hack.rb @@ -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', diff --git a/test/functional/admin_controller_test.rb b/test/functional/admin_controller_test.rb index 3ca5ef85..89b164c5 100644 --- a/test/functional/admin_controller_test.rb +++ b/test/functional/admin_controller_test.rb @@ -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 diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index d6d091a8..bf3b64ec 100755 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -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'