Project

General

Profile

Defect #35248 » issue-35248-localize-issue-status-errors.diff

Martin Glaser, 2026-06-21 21:52

View differences:

app/models/issue_status.rb
def check_integrity
if Issue.where(:status_id => id).any?
raise "This status is used by some issues"
raise l(:error_issue_status_in_use_by_issues)
elsif Tracker.where(:default_status_id => id).any?
raise "This status is used as the default status by some trackers"
raise l(:error_issue_status_default_for_trackers)
end
end
config/locales/en.yml
error_workflow_copy_source: 'Please select a source tracker or role'
error_workflow_copy_target: 'Please select target tracker(s) and role(s)'
error_unable_delete_issue_status: 'Unable to delete issue status (%{value})'
error_issue_status_in_use_by_issues: "This status is used by some issues"
error_issue_status_default_for_trackers: "This status is used as the default status by some trackers"
error_unable_to_connect: "Unable to connect (%{value})"
error_attachments_too_many: "This file cannot be uploaded because it exceeds the maximum number of files that can be attached simultaneously (%{max_number_of_files})"
error_attachment_too_big: "This file cannot be uploaded because it exceeds the maximum allowed file size (%{max_size})"
test/unit/issue_status_test.rb
def test_destroy_status_in_use
# Status assigned to an Issue
status = Issue.find(1).status
assert_raise(RuntimeError, "Cannot delete status") {status.destroy}
e = assert_raise(RuntimeError) {status.destroy}
assert_equal I18n.t(:error_issue_status_in_use_by_issues), e.message
end
def test_destroy_status_used_as_default_by_tracker
# Status that is not used by any issue but is the default status of a tracker
status = IssueStatus.find(3)
assert_not Issue.where(:status_id => status.id).exists?
Tracker.find(1).update_column(:default_status_id, status.id)
e = assert_raise(RuntimeError) {status.destroy}
assert_equal I18n.t(:error_issue_status_default_for_trackers), e.message
end
def test_new_statuses_allowed_to
(2-2/2)