summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/wiki_controller.rb10
-rw-r--r--test/integration/api_test/wiki_pages_test.rb9
-rw-r--r--test/integration/routing/wiki_test.rb10
3 files changed, 26 insertions, 3 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index 51e2ef367..9c6a4cf20 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_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
diff --git a/test/integration/api_test/wiki_pages_test.rb b/test/integration/api_test/wiki_pages_test.rb
index f9ec2bfe7..93db5aa51 100644
--- a/test/integration/api_test/wiki_pages_test.rb
+++ b/test/integration/api_test/wiki_pages_test.rb
@@ -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
diff --git a/test/integration/routing/wiki_test.rb b/test/integration/routing/wiki_test.rb
index 2c85a62ee..5deeb7ee1 100644
--- a/test/integration/routing/wiki_test.rb
+++ b/test/integration/routing/wiki_test.rb
@@ -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