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
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
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
{ :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