summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/trackers_controller.rb6
-rw-r--r--config/locales/en.yml2
-rw-r--r--test/functional/trackers_controller_test.rb16
3 files changed, 19 insertions, 5 deletions
diff --git a/app/controllers/trackers_controller.rb b/app/controllers/trackers_controller.rb
index c1415bc2c..824ce93ef 100644
--- a/app/controllers/trackers_controller.rb
+++ b/app/controllers/trackers_controller.rb
@@ -89,7 +89,11 @@ class TrackersController < ApplicationController
def destroy
@tracker = Tracker.find(params[:id])
unless @tracker.issues.empty?
- flash[:error] = l(:error_can_not_delete_tracker)
+ 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))
+ end.join(', ')
+ flash[:error] = l(:error_can_not_delete_tracker_html, projects: links.html_safe)
else
@tracker.destroy
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 200bdcdfc..cea117d09 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -205,7 +205,7 @@ en:
error_no_tracker_in_project: 'No tracker is associated to this project. Please check the Project settings.'
error_no_default_issue_status: 'No default issue status is defined. Please check your configuration (Go to "Administration -> Issue statuses").'
error_can_not_delete_custom_field: Unable to delete custom field
- error_can_not_delete_tracker: "This tracker contains issues and cannot be deleted."
+ error_can_not_delete_tracker_html: "This tracker contains issues and cannot be deleted.<p>The following projects have issues with this tracker:<br>%{projects}</p>"
error_can_not_remove_role: "This role is in use and cannot be deleted."
error_can_not_reopen_issue_on_closed_version: 'An issue assigned to a closed version cannot be reopened'
error_can_not_archive_project: This project cannot be archived
diff --git a/test/functional/trackers_controller_test.rb b/test/functional/trackers_controller_test.rb
index c2d2405e3..6f62c9f0a 100644
--- a/test/functional/trackers_controller_test.rb
+++ b/test/functional/trackers_controller_test.rb
@@ -274,11 +274,21 @@ class TrackersControllerTest < Redmine::ControllerTest
end
def test_destroy_tracker_in_use
+ tracker = Tracker.generate!(name: 'In use')
+ projects = Array.new(2) do
+ project = Project.generate!
+ Issue.generate!(project: project, tracker: tracker)
+ project
+ end
+
assert_no_difference 'Tracker.count' do
- delete :destroy, :params => {:id => 1}
+ delete :destroy, params: {id: tracker.id}
+ end
+ assert_redirected_to action: 'index'
+ assert_match /The following projects have issues with this tracker:/, flash[:error]
+ projects.each do |project|
+ assert_match /#{project.name}/, flash[:error]
end
- assert_redirected_to :action => 'index'
- assert_not_nil flash[:error]
end
def test_get_fields