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
114 114

  
115 115
  def check_integrity
116 116
    if Issue.where(:status_id => id).any?
117
      raise "This status is used by some issues"
117
      raise l(:error_issue_status_in_use_by_issues)
118 118
    elsif Tracker.where(:default_status_id => id).any?
119
      raise "This status is used as the default status by some trackers"
119
      raise l(:error_issue_status_default_for_trackers)
120 120
    end
121 121
  end
122 122

  
config/locales/en.yml
218 218
  error_workflow_copy_source: 'Please select a source tracker or role'
219 219
  error_workflow_copy_target: 'Please select target tracker(s) and role(s)'
220 220
  error_unable_delete_issue_status: 'Unable to delete issue status (%{value})'
221
  error_issue_status_in_use_by_issues: "This status is used by some issues"
222
  error_issue_status_default_for_trackers: "This status is used as the default status by some trackers"
221 223
  error_unable_to_connect: "Unable to connect (%{value})"
222 224
  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})"
223 225
  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
46 46
  def test_destroy_status_in_use
47 47
    # Status assigned to an Issue
48 48
    status = Issue.find(1).status
49
    assert_raise(RuntimeError, "Cannot delete status") {status.destroy}
49
    e = assert_raise(RuntimeError) {status.destroy}
50
    assert_equal I18n.t(:error_issue_status_in_use_by_issues), e.message
51
  end
52

  
53
  def test_destroy_status_used_as_default_by_tracker
54
    # Status that is not used by any issue but is the default status of a tracker
55
    status = IssueStatus.find(3)
56
    assert_not Issue.where(:status_id => status.id).exists?
57
    Tracker.find(1).update_column(:default_status_id, status.id)
58

  
59
    e = assert_raise(RuntimeError) {status.destroy}
60
    assert_equal I18n.t(:error_issue_status_default_for_trackers), e.message
50 61
  end
51 62

  
52 63
  def test_new_statuses_allowed_to
(2-2/2)