summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/wiki_controller.rb5
-rw-r--r--app/views/wiki/destroy.rhtml2
-rw-r--r--app/views/wiki/show.rhtml2
-rw-r--r--config/routes.rb4
-rw-r--r--test/functional/wiki_controller_test.rb10
-rw-r--r--test/integration/routing_test.rb3
6 files changed, 15 insertions, 11 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index c7b866239..4f15d35a0 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -36,7 +36,7 @@ class WikiController < ApplicationController
before_filter :find_wiki, :authorize
before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy]
- verify :method => :post, :only => [:destroy, :protect], :redirect_to => { :action => :show }
+ verify :method => :post, :only => [:protect], :redirect_to => { :action => :show }
helper :attachments
include AttachmentsHelper
@@ -172,7 +172,8 @@ class WikiController < ApplicationController
@annotate = @page.annotate(params[:version])
render_404 unless @annotate
end
-
+
+ verify :method => :delete, :only => [:destroy], :redirect_to => { :action => :show }
# Removes a wiki page and its history
# Children can be either set as root pages, removed or reassigned to another parent page
def destroy
diff --git a/app/views/wiki/destroy.rhtml b/app/views/wiki/destroy.rhtml
index 83c81fd5c..99f470320 100644
--- a/app/views/wiki/destroy.rhtml
+++ b/app/views/wiki/destroy.rhtml
@@ -1,6 +1,6 @@
<h2><%=h @page.pretty_title %></h2>
-<% form_tag({}) do %>
+<% form_tag({}, :method => :delete) do %>
<div class="box">
<p><strong><%= l(:text_wiki_page_destroy_question, :descendants => @descendants_count) %></strong></p>
<p><label><%= radio_button_tag 'todo', 'nullify', true %> <%= l(:text_wiki_page_nullify_children) %></label><br />
diff --git a/app/views/wiki/show.rhtml b/app/views/wiki/show.rhtml
index f8675608e..d8bc8c55e 100644
--- a/app/views/wiki/show.rhtml
+++ b/app/views/wiki/show.rhtml
@@ -5,7 +5,7 @@
<%= link_to_if_authorized(l(:button_lock), {:action => 'protect', :page => @page.title, :protected => 1}, :method => :post, :class => 'icon icon-lock') if !@page.protected? %>
<%= link_to_if_authorized(l(:button_unlock), {:action => 'protect', :page => @page.title, :protected => 0}, :method => :post, :class => 'icon icon-unlock') if @page.protected? %>
<%= link_to_if_authorized(l(:button_rename), {:action => 'rename', :page => @page.title}, :class => 'icon icon-move') if @content.version == @page.content.version %>
-<%= link_to_if_authorized(l(:button_delete), {:action => 'destroy', :page => @page.title}, :method => :post, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
+<%= link_to_if_authorized(l(:button_delete), {:action => 'destroy', :page => @page.title}, :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
<%= link_to_if_authorized(l(:button_rollback), {:action => 'edit', :page => @page.title, :version => @content.version }, :class => 'icon icon-cancel') if @content.version < @page.content.version %>
<% end %>
<%= link_to_if_authorized(l(:label_history), {:action => 'history', :page => @page.title}, :class => 'icon icon-history') %>
diff --git a/config/routes.rb b/config/routes.rb
index 5ca9d86d1..63c7dd765 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -41,10 +41,12 @@ ActionController::Routing::Routes.draw do |map|
end
wiki_routes.connect 'projects/:project_id/wiki/:page/:action',
- :action => /rename|destroy|preview|protect|add_attachment/,
+ :action => /rename|preview|protect|add_attachment/,
:conditions => {:method => :post}
wiki_routes.connect 'projects/:project_id/wiki/:page/edit', :action => 'update', :conditions => {:method => :post}
+
+ wiki_routes.connect 'projects/:project_id/wiki/:page', :action => 'destroy', :conditions => {:method => :delete}
end
map.with_options :controller => 'messages' do |messages_routes|
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb
index fecde6159..9124dad34 100644
--- a/test/functional/wiki_controller_test.rb
+++ b/test/functional/wiki_controller_test.rb
@@ -196,14 +196,14 @@ class WikiControllerTest < ActionController::TestCase
def test_destroy_child
@request.session[:user_id] = 2
- post :destroy, :project_id => 1, :page => 'Child_1'
+ delete :destroy, :project_id => 1, :page => 'Child_1'
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
end
def test_destroy_parent
@request.session[:user_id] = 2
assert_no_difference('WikiPage.count') do
- post :destroy, :project_id => 1, :page => 'Another_page'
+ delete :destroy, :project_id => 1, :page => 'Another_page'
end
assert_response :success
assert_template 'destroy'
@@ -212,7 +212,7 @@ class WikiControllerTest < ActionController::TestCase
def test_destroy_parent_with_nullify
@request.session[:user_id] = 2
assert_difference('WikiPage.count', -1) do
- post :destroy, :project_id => 1, :page => 'Another_page', :todo => 'nullify'
+ delete :destroy, :project_id => 1, :page => 'Another_page', :todo => 'nullify'
end
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_nil WikiPage.find_by_id(2)
@@ -221,7 +221,7 @@ class WikiControllerTest < ActionController::TestCase
def test_destroy_parent_with_cascade
@request.session[:user_id] = 2
assert_difference('WikiPage.count', -3) do
- post :destroy, :project_id => 1, :page => 'Another_page', :todo => 'destroy'
+ delete :destroy, :project_id => 1, :page => 'Another_page', :todo => 'destroy'
end
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_nil WikiPage.find_by_id(2)
@@ -231,7 +231,7 @@ class WikiControllerTest < ActionController::TestCase
def test_destroy_parent_with_reassign
@request.session[:user_id] = 2
assert_difference('WikiPage.count', -1) do
- post :destroy, :project_id => 1, :page => 'Another_page', :todo => 'reassign', :reassign_to_id => 1
+ delete :destroy, :project_id => 1, :page => 'Another_page', :todo => 'reassign', :reassign_to_id => 1
end
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_nil WikiPage.find_by_id(2)
diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb
index c749f51e4..e41a04bd2 100644
--- a/test/integration/routing_test.rb
+++ b/test/integration/routing_test.rb
@@ -325,9 +325,10 @@ class RoutingTest < ActionController::IntegrationTest
should_route :post, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'update', :project_id => '567', :page => 'my_page'
should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :project_id => '567', :page => 'CookBook_documentation'
should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :page => 'ladida'
- should_route :post, "/projects/22/wiki/ladida/destroy", :controller => 'wiki', :action => 'destroy', :project_id => '22', :page => 'ladida'
should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :project_id => '22', :page => 'ladida'
should_route :post, "/projects/22/wiki/ladida/add_attachment", :controller => 'wiki', :action => 'add_attachment', :project_id => '22', :page => 'ladida'
+
+ should_route :delete, "/projects/22/wiki/ladida", :controller => 'wiki', :action => 'destroy', :project_id => '22', :page => 'ladida'
end
context "wikis (plural, admin setup)" do