##// END OF EJS Templates
Changed IssuesController#destroy to DELETE only....
Jean-Philippe Lang -
r8030:52a7fa6176c8
parent child
Show More
@@ -54,10 +54,6 class IssuesController < ApplicationController
54 54 helper :gantt
55 55 include Redmine::Export::PDF
56 56
57 verify :method => [:post, :delete],
58 :only => :destroy,
59 :render => { :nothing => true, :status => :method_not_allowed }
60
61 57 verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
62 58 verify :method => :post, :only => :bulk_update, :render => {:nothing => true, :status => :method_not_allowed }
63 59 verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
@@ -225,6 +221,7 class IssuesController < ApplicationController
225 221 redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project})
226 222 end
227 223
224 verify :method => :delete, :only => :destroy, :render => { :nothing => true, :status => :method_not_allowed }
228 225 def destroy
229 226 @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
230 227 if @hours > 0
@@ -114,8 +114,8
114 114 :class => 'icon-copy', :disabled => !@can[:move] %></li>
115 115 <li><%= context_menu_link l(:button_move), new_issue_move_path(:ids => @issues.collect(&:id)),
116 116 :class => 'icon-move', :disabled => !@can[:move] %></li>
117 <li><%= context_menu_link l(:button_delete), {:controller => 'issues', :action => 'destroy', :ids => @issues.collect(&:id), :back_url => @back},
118 :method => :post, :confirm => issues_destroy_confirmation_message(@issues), :class => 'icon-del', :disabled => !@can[:delete] %></li>
117 <li><%= context_menu_link l(:button_delete), issues_path(:ids => @issues.collect(&:id), :back_url => @back),
118 :method => :delete, :confirm => issues_destroy_confirmation_message(@issues), :class => 'icon-del', :disabled => !@can[:delete] %></li>
119 119
120 120 <%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
121 121 </ul>
@@ -5,5 +5,5
5 5 <%= link_to_if_authorized l(:button_duplicate), {:controller => 'issues', :action => 'new', :project_id => @project, :copy_from => @issue }, :class => 'icon icon-duplicate' %>
6 6 <%= link_to_if_authorized l(:button_copy), {:controller => 'issue_moves', :action => 'new', :id => @issue, :copy_options => {:copy => 't'}}, :class => 'icon icon-copy' %>
7 7 <%= link_to_if_authorized l(:button_move), {:controller => 'issue_moves', :action => 'new', :id => @issue}, :class => 'icon icon-move' %>
8 <%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => issues_destroy_confirmation_message(@issue), :method => :post, :class => 'icon icon-del' %>
8 <%= link_to l(:button_delete), issue_path(@issue), :confirm => issues_destroy_confirmation_message(@issue), :method => :delete, :class => 'icon icon-del' if User.current.allowed_to?(:delete_issues, @project) %>
9 9 </div>
@@ -45,7 +45,6 ActionController::Routing::Routes.draw do |map|
45 45 map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues'
46 46 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
47 47 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post }
48 map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy
49 48
50 49 map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes|
51 50 gantts_routes.connect '/projects/:project_id/issues/gantt'
@@ -67,6 +66,8 ActionController::Routing::Routes.draw do |map|
67 66 issues.resources :time_entries, :controller => 'timelog', :collection => {:report => :get}
68 67 issues.resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
69 68 end
69 # Bulk deletion
70 map.connect '/issues', :controller => 'issues', :action => 'destroy', :conditions => {:method => :delete}
70 71
71 72 map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new'
72 73
@@ -1997,14 +1997,14 class IssuesControllerTest < ActionController::TestCase
1997 1997 def test_destroy_issue_with_no_time_entries
1998 1998 assert_nil TimeEntry.find_by_issue_id(2)
1999 1999 @request.session[:user_id] = 2
2000 post :destroy, :id => 2
2000 delete :destroy, :id => 2
2001 2001 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
2002 2002 assert_nil Issue.find_by_id(2)
2003 2003 end
2004 2004
2005 2005 def test_destroy_issues_with_time_entries
2006 2006 @request.session[:user_id] = 2
2007 post :destroy, :ids => [1, 3]
2007 delete :destroy, :ids => [1, 3]
2008 2008 assert_response :success
2009 2009 assert_template 'destroy'
2010 2010 assert_not_nil assigns(:hours)
@@ -2013,7 +2013,7 class IssuesControllerTest < ActionController::TestCase
2013 2013
2014 2014 def test_destroy_issues_and_destroy_time_entries
2015 2015 @request.session[:user_id] = 2
2016 post :destroy, :ids => [1, 3], :todo => 'destroy'
2016 delete :destroy, :ids => [1, 3], :todo => 'destroy'
2017 2017 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
2018 2018 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
2019 2019 assert_nil TimeEntry.find_by_id([1, 2])
@@ -2021,7 +2021,7 class IssuesControllerTest < ActionController::TestCase
2021 2021
2022 2022 def test_destroy_issues_and_assign_time_entries_to_project
2023 2023 @request.session[:user_id] = 2
2024 post :destroy, :ids => [1, 3], :todo => 'nullify'
2024 delete :destroy, :ids => [1, 3], :todo => 'nullify'
2025 2025 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
2026 2026 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
2027 2027 assert_nil TimeEntry.find(1).issue_id
@@ -2030,7 +2030,7 class IssuesControllerTest < ActionController::TestCase
2030 2030
2031 2031 def test_destroy_issues_and_reassign_time_entries_to_another_issue
2032 2032 @request.session[:user_id] = 2
2033 post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
2033 delete :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
2034 2034 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
2035 2035 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
2036 2036 assert_equal 2, TimeEntry.find(1).issue_id
@@ -2039,7 +2039,7 class IssuesControllerTest < ActionController::TestCase
2039 2039
2040 2040 def test_destroy_issues_from_different_projects
2041 2041 @request.session[:user_id] = 2
2042 post :destroy, :ids => [1, 2, 6], :todo => 'destroy'
2042 delete :destroy, :ids => [1, 2, 6], :todo => 'destroy'
2043 2043 assert_redirected_to :controller => 'issues', :action => 'index'
2044 2044 assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6))
2045 2045 end
@@ -2051,7 +2051,7 class IssuesControllerTest < ActionController::TestCase
2051 2051
2052 2052 @request.session[:user_id] = 2
2053 2053 assert_difference 'Issue.count', -2 do
2054 post :destroy, :ids => [parent.id, child.id], :todo => 'destroy'
2054 delete :destroy, :ids => [parent.id, child.id], :todo => 'destroy'
2055 2055 end
2056 2056 assert_response 302
2057 2057 end
General Comments 0
You need to be logged in to leave comments. Login now