##// END OF EJS Templates
REST API for deleting wiki pages (#7082)....
Jean-Philippe Lang -
r10528:beb261065059
parent child
Show More
@@ -36,7 +36,7 class WikiController < ApplicationController
36 before_filter :find_wiki, :authorize
36 before_filter :find_wiki, :authorize
37 before_filter :find_existing_or_new_page, :only => [:show, :edit, :update]
37 before_filter :find_existing_or_new_page, :only => [:show, :edit, :update]
38 before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy, :destroy_version]
38 before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy, :destroy_version]
39 accept_api_auth :index, :show, :update
39 accept_api_auth :index, :show, :update, :destroy
40
40
41 helper :attachments
41 helper :attachments
42 include AttachmentsHelper
42 include AttachmentsHelper
@@ -263,11 +263,15 class WikiController < ApplicationController
263 end
263 end
264 else
264 else
265 @reassignable_to = @wiki.pages - @page.self_and_descendants
265 @reassignable_to = @wiki.pages - @page.self_and_descendants
266 return
266 # display the destroy form if it's a user request
267 return unless api_request?
267 end
268 end
268 end
269 end
269 @page.destroy
270 @page.destroy
270 redirect_to :action => 'index', :project_id => @project
271 respond_to do |format|
272 format.html { redirect_to :action => 'index', :project_id => @project }
273 format.api { render_api_ok }
274 end
271 end
275 end
272
276
273 def destroy_version
277 def destroy_version
@@ -181,4 +181,13 class ApiTest::WikiPagesTest < ActionController::IntegrationTest
181 assert_equal 'New_subpage_from_API', page.title
181 assert_equal 'New_subpage_from_API', page.title
182 assert_equal WikiPage.find(1), page.parent
182 assert_equal WikiPage.find(1), page.parent
183 end
183 end
184
185 test "DELETE /projects/:project_id/wiki/:title.xml should destroy the page" do
186 assert_difference 'WikiPage.count', -1 do
187 delete '/projects/ecookbook/wiki/CookBook_documentation.xml', {}, credentials('jsmith')
188 assert_response 200
189 end
190
191 assert_nil WikiPage.find_by_id(1)
192 end
184 end
193 end
@@ -168,5 +168,15 class RoutingWikiTest < ActionController::IntegrationTest
168 { :controller => 'wiki', :action => 'update', :project_id => '567',
168 { :controller => 'wiki', :action => 'update', :project_id => '567',
169 :id => 'my_page', :format => 'json' }
169 :id => 'my_page', :format => 'json' }
170 )
170 )
171 assert_routing(
172 { :method => 'delete', :path => "/projects/567/wiki/my_page.xml" },
173 { :controller => 'wiki', :action => 'destroy', :project_id => '567',
174 :id => 'my_page', :format => 'xml' }
175 )
176 assert_routing(
177 { :method => 'delete', :path => "/projects/567/wiki/my_page.json" },
178 { :controller => 'wiki', :action => 'destroy', :project_id => '567',
179 :id => 'my_page', :format => 'json' }
180 )
171 end
181 end
172 end
182 end
General Comments 0
You need to be logged in to leave comments. Login now