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