Defect #43174 ยป Fix-CookieOverflow-error-when-deleting-tracker.patch
| app/controllers/trackers_controller.rb | ||
|---|---|---|
| 88 | 88 | |
| 89 | 89 |
def destroy |
| 90 | 90 |
@tracker = Tracker.find(params[:id]) |
| 91 |
unless @tracker.issues.empty? |
|
| 91 |
if @tracker.issues.empty? |
|
| 92 |
@tracker.destroy |
|
| 93 |
redirect_to trackers_path |
|
| 94 |
else |
|
| 92 | 95 |
projects = Project.joins(:issues).where(issues: {tracker_id: @tracker.id}).sorted.distinct
|
| 93 | 96 |
links = projects.map do |p| |
| 94 | 97 |
view_context.link_to(p, project_issues_path(p, set_filter: 1, tracker_id: @tracker.id, status_id: '*')) |
| 95 | 98 |
end.join(', ')
|
| 96 |
flash[:error] = l(:error_can_not_delete_tracker_html, projects: links.html_safe) |
|
| 97 |
else
|
|
| 98 |
@tracker.destroy
|
|
| 99 |
flash.now[:error] = l(:error_can_not_delete_tracker_html, projects: links.html_safe)
|
|
| 100 |
@trackers = Tracker.sorted.preload(:default_status).to_a
|
|
| 101 |
render :index
|
|
| 99 | 102 |
end |
| 100 |
redirect_to trackers_path |
|
| 101 | 103 |
end |
| 102 | 104 | |
| 103 | 105 |
def fields |
| test/functional/trackers_controller_test.rb | ||
|---|---|---|
| 282 | 282 |
assert_no_difference 'Tracker.count' do |
| 283 | 283 |
delete :destroy, params: {id: tracker.id}
|
| 284 | 284 |
end |
| 285 |
assert_redirected_to action: 'index'
|
|
| 285 |
assert_response :success
|
|
| 286 | 286 |
assert_match /The following projects have issues with this tracker:/, flash[:error] |
| 287 | 287 |
projects.each do |project| |
| 288 | 288 |
assert_match /#{project.name}/, flash[:error]
|