@@ -36,7 +36,7 class WikiController < ApplicationController | |||
|
36 | 36 | before_filter :find_wiki, :authorize |
|
37 | 37 | before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy] |
|
38 | 38 | |
|
39 |
verify :method => :post, :only => [ |
|
|
39 | verify :method => :post, :only => [:protect], :redirect_to => { :action => :show } | |
|
40 | 40 | |
|
41 | 41 | helper :attachments |
|
42 | 42 | include AttachmentsHelper |
@@ -172,7 +172,8 class WikiController < ApplicationController | |||
|
172 | 172 | @annotate = @page.annotate(params[:version]) |
|
173 | 173 | render_404 unless @annotate |
|
174 | 174 | end |
|
175 | ||
|
175 | ||
|
176 | verify :method => :delete, :only => [:destroy], :redirect_to => { :action => :show } | |
|
176 | 177 | # Removes a wiki page and its history |
|
177 | 178 | # Children can be either set as root pages, removed or reassigned to another parent page |
|
178 | 179 | def destroy |
@@ -1,6 +1,6 | |||
|
1 | 1 | <h2><%=h @page.pretty_title %></h2> |
|
2 | 2 | |
|
3 | <% form_tag({}) do %> | |
|
3 | <% form_tag({}, :method => :delete) do %> | |
|
4 | 4 | <div class="box"> |
|
5 | 5 | <p><strong><%= l(:text_wiki_page_destroy_question, :descendants => @descendants_count) %></strong></p> |
|
6 | 6 | <p><label><%= radio_button_tag 'todo', 'nullify', true %> <%= l(:text_wiki_page_nullify_children) %></label><br /> |
@@ -5,7 +5,7 | |||
|
5 | 5 | <%= link_to_if_authorized(l(:button_lock), {:action => 'protect', :page => @page.title, :protected => 1}, :method => :post, :class => 'icon icon-lock') if !@page.protected? %> |
|
6 | 6 | <%= link_to_if_authorized(l(:button_unlock), {:action => 'protect', :page => @page.title, :protected => 0}, :method => :post, :class => 'icon icon-unlock') if @page.protected? %> |
|
7 | 7 | <%= link_to_if_authorized(l(:button_rename), {:action => 'rename', :page => @page.title}, :class => 'icon icon-move') if @content.version == @page.content.version %> |
|
8 |
<%= link_to_if_authorized(l(:button_delete), {:action => 'destroy', :page => @page.title}, :method => : |
|
|
8 | <%= link_to_if_authorized(l(:button_delete), {:action => 'destroy', :page => @page.title}, :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %> | |
|
9 | 9 | <%= 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 %> |
|
10 | 10 | <% end %> |
|
11 | 11 | <%= link_to_if_authorized(l(:label_history), {:action => 'history', :page => @page.title}, :class => 'icon icon-history') %> |
@@ -41,10 +41,12 ActionController::Routing::Routes.draw do |map| | |||
|
41 | 41 | end |
|
42 | 42 | |
|
43 | 43 | wiki_routes.connect 'projects/:project_id/wiki/:page/:action', |
|
44 |
:action => /rename| |
|
|
44 | :action => /rename|preview|protect|add_attachment/, | |
|
45 | 45 | :conditions => {:method => :post} |
|
46 | 46 | |
|
47 | 47 | wiki_routes.connect 'projects/:project_id/wiki/:page/edit', :action => 'update', :conditions => {:method => :post} |
|
48 | ||
|
49 | wiki_routes.connect 'projects/:project_id/wiki/:page', :action => 'destroy', :conditions => {:method => :delete} | |
|
48 | 50 | end |
|
49 | 51 | |
|
50 | 52 | map.with_options :controller => 'messages' do |messages_routes| |
@@ -196,14 +196,14 class WikiControllerTest < ActionController::TestCase | |||
|
196 | 196 | |
|
197 | 197 | def test_destroy_child |
|
198 | 198 | @request.session[:user_id] = 2 |
|
199 |
|
|
|
199 | delete :destroy, :project_id => 1, :page => 'Child_1' | |
|
200 | 200 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
201 | 201 | end |
|
202 | 202 | |
|
203 | 203 | def test_destroy_parent |
|
204 | 204 | @request.session[:user_id] = 2 |
|
205 | 205 | assert_no_difference('WikiPage.count') do |
|
206 |
|
|
|
206 | delete :destroy, :project_id => 1, :page => 'Another_page' | |
|
207 | 207 | end |
|
208 | 208 | assert_response :success |
|
209 | 209 | assert_template 'destroy' |
@@ -212,7 +212,7 class WikiControllerTest < ActionController::TestCase | |||
|
212 | 212 | def test_destroy_parent_with_nullify |
|
213 | 213 | @request.session[:user_id] = 2 |
|
214 | 214 | assert_difference('WikiPage.count', -1) do |
|
215 |
|
|
|
215 | delete :destroy, :project_id => 1, :page => 'Another_page', :todo => 'nullify' | |
|
216 | 216 | end |
|
217 | 217 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
218 | 218 | assert_nil WikiPage.find_by_id(2) |
@@ -221,7 +221,7 class WikiControllerTest < ActionController::TestCase | |||
|
221 | 221 | def test_destroy_parent_with_cascade |
|
222 | 222 | @request.session[:user_id] = 2 |
|
223 | 223 | assert_difference('WikiPage.count', -3) do |
|
224 |
|
|
|
224 | delete :destroy, :project_id => 1, :page => 'Another_page', :todo => 'destroy' | |
|
225 | 225 | end |
|
226 | 226 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
227 | 227 | assert_nil WikiPage.find_by_id(2) |
@@ -231,7 +231,7 class WikiControllerTest < ActionController::TestCase | |||
|
231 | 231 | def test_destroy_parent_with_reassign |
|
232 | 232 | @request.session[:user_id] = 2 |
|
233 | 233 | assert_difference('WikiPage.count', -1) do |
|
234 |
|
|
|
234 | delete :destroy, :project_id => 1, :page => 'Another_page', :todo => 'reassign', :reassign_to_id => 1 | |
|
235 | 235 | end |
|
236 | 236 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
237 | 237 | assert_nil WikiPage.find_by_id(2) |
@@ -325,9 +325,10 class RoutingTest < ActionController::IntegrationTest | |||
|
325 | 325 | should_route :post, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'update', :project_id => '567', :page => 'my_page' |
|
326 | 326 | should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :project_id => '567', :page => 'CookBook_documentation' |
|
327 | 327 | should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :page => 'ladida' |
|
328 | should_route :post, "/projects/22/wiki/ladida/destroy", :controller => 'wiki', :action => 'destroy', :project_id => '22', :page => 'ladida' | |
|
329 | 328 | should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :project_id => '22', :page => 'ladida' |
|
330 | 329 | should_route :post, "/projects/22/wiki/ladida/add_attachment", :controller => 'wiki', :action => 'add_attachment', :project_id => '22', :page => 'ladida' |
|
330 | ||
|
331 | should_route :delete, "/projects/22/wiki/ladida", :controller => 'wiki', :action => 'destroy', :project_id => '22', :page => 'ladida' | |
|
331 | 332 | end |
|
332 | 333 | |
|
333 | 334 | context "wikis (plural, admin setup)" do |
General Comments 0
You need to be logged in to leave comments.
Login now