##// END OF EJS Templates
Fixed: bulk destroying parent and child issues raises a stale object error (#7920)....
Jean-Philippe Lang -
r5163:4e7835c68c7d
parent child
Show More
@@ -236,7 +236,13 class IssuesController < ApplicationController
236 236 return unless api_request?
237 237 end
238 238 end
239 @issues.each(&:destroy)
239 @issues.each do |issue|
240 begin
241 issue.reload.destroy
242 rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists
243 # nothing to do, issue was already deleted (eg. by a parent)
244 end
245 end
240 246 respond_to do |format|
241 247 format.html { redirect_back_or_default(:action => 'index', :project_id => @project) }
242 248 format.api { head :ok }
@@ -1323,6 +1323,18 class IssuesControllerTest < ActionController::TestCase
1323 1323 assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6))
1324 1324 end
1325 1325
1326 def test_destroy_parent_and_child_issues
1327 parent = Issue.generate!(:project_id => 1, :tracker_id => 1)
1328 child = Issue.generate!(:project_id => 1, :tracker_id => 1, :parent_issue_id => parent.id)
1329 assert child.is_descendant_of?(parent.reload)
1330
1331 @request.session[:user_id] = 2
1332 assert_difference 'Issue.count', -2 do
1333 post :destroy, :ids => [parent.id, child.id], :todo => 'destroy'
1334 end
1335 assert_response 302
1336 end
1337
1326 1338 def test_default_search_scope
1327 1339 get :index
1328 1340 assert_tag :div, :attributes => {:id => 'quick-search'},
General Comments 0
You need to be logged in to leave comments. Login now