Feature #12521 » 12521-v2.patch
| app/controllers/trackers_controller.rb | ||
|---|---|---|
|
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
|
||
| config/locales/en.yml | ||
|---|---|---|
|
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
|
||
| test/functional/trackers_controller_test.rb | ||
|---|---|---|
|
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
|
||