git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10743 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/2.2.0
@@ -36,7 +36,7 @@ class WikiController < ApplicationController | |||
before_filter :find_wiki, :authorize | |||
before_filter :find_existing_or_new_page, :only => [:show, :edit, :update] | |||
before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy, :destroy_version] | |||
accept_api_auth :index, :show, :update | |||
accept_api_auth :index, :show, :update, :destroy | |||
helper :attachments | |||
include AttachmentsHelper | |||
@@ -263,11 +263,15 @@ class WikiController < ApplicationController | |||
end | |||
else | |||
@reassignable_to = @wiki.pages - @page.self_and_descendants | |||
return | |||
# display the destroy form if it's a user request | |||
return unless api_request? | |||
end | |||
end | |||
@page.destroy | |||
redirect_to :action => 'index', :project_id => @project | |||
respond_to do |format| | |||
format.html { redirect_to :action => 'index', :project_id => @project } | |||
format.api { render_api_ok } | |||
end | |||
end | |||
def destroy_version |
@@ -181,4 +181,13 @@ class ApiTest::WikiPagesTest < ActionController::IntegrationTest | |||
assert_equal 'New_subpage_from_API', page.title | |||
assert_equal WikiPage.find(1), page.parent | |||
end | |||
test "DELETE /projects/:project_id/wiki/:title.xml should destroy the page" do | |||
assert_difference 'WikiPage.count', -1 do | |||
delete '/projects/ecookbook/wiki/CookBook_documentation.xml', {}, credentials('jsmith') | |||
assert_response 200 | |||
end | |||
assert_nil WikiPage.find_by_id(1) | |||
end | |||
end |
@@ -168,5 +168,15 @@ class RoutingWikiTest < ActionController::IntegrationTest | |||
{ :controller => 'wiki', :action => 'update', :project_id => '567', | |||
:id => 'my_page', :format => 'json' } | |||
) | |||
assert_routing( | |||
{ :method => 'delete', :path => "/projects/567/wiki/my_page.xml" }, | |||
{ :controller => 'wiki', :action => 'destroy', :project_id => '567', | |||
:id => 'my_page', :format => 'xml' } | |||
) | |||
assert_routing( | |||
{ :method => 'delete', :path => "/projects/567/wiki/my_page.json" }, | |||
{ :controller => 'wiki', :action => 'destroy', :project_id => '567', | |||
:id => 'my_page', :format => 'json' } | |||
) | |||
end | |||
end |