Defect #43174 ยป Fix-CookieOverflow-error-when-deleting-tracker.patch
| app/controllers/trackers_controller.rb | ||
|---|---|---|
|
def destroy
|
||
|
@tracker = Tracker.find(params[:id])
|
||
|
unless @tracker.issues.empty?
|
||
|
if @tracker.issues.empty?
|
||
|
@tracker.destroy
|
||
|
redirect_to trackers_path
|
||
|
else
|
||
|
projects = Project.joins(:issues).where(issues: {tracker_id: @tracker.id}).sorted.distinct
|
||
|
links = projects.map do |p|
|
||
|
view_context.link_to(p, project_issues_path(p, set_filter: 1, tracker_id: @tracker.id, status_id: '*'))
|
||
|
end.join(', ')
|
||
|
flash[:error] = l(:error_can_not_delete_tracker_html, projects: links.html_safe)
|
||
|
else
|
||
|
@tracker.destroy
|
||
|
flash.now[:error] = l(:error_can_not_delete_tracker_html, projects: links.html_safe)
|
||
|
@trackers = Tracker.sorted.preload(:default_status).to_a
|
||
|
render :index
|
||
|
end
|
||
|
redirect_to trackers_path
|
||
|
end
|
||
|
def fields
|
||
| test/functional/trackers_controller_test.rb | ||
|---|---|---|
|
assert_no_difference 'Tracker.count' do
|
||
|
delete :destroy, params: {id: tracker.id}
|
||
|
end
|
||
|
assert_redirected_to action: 'index'
|
||
|
assert_response :success
|
||
|
assert_match /The following projects have issues with this tracker:/, flash[:error]
|
||
|
projects.each do |project|
|
||
|
assert_match /#{project.name}/, flash[:error]
|
||