Project

General

Profile

Defect #8539 ยป 8539.patch

Go MAEDA, 2024-09-07 10:38

View differences:

app/models/issue.rb
1018 1018

  
1019 1019
  # Returns true if this issue is blocked by another issue that is still open
1020 1020
  def blocked?
1021
    !relations_to.detect {|ir| ir.relation_type == 'blocks' && !ir.issue_from.closed?}.nil?
1021
    relations_to.any? {|ir| ir.relation_type == 'blocks' && ir.issue_from&.closed? == false}
1022 1022
  end
1023 1023

  
1024 1024
  # Returns true if this issue can be closed and if not, returns false and populates the reason
test/unit/issue_test.rb
2222 2222
    assert !blocking_issue.blocked?
2223 2223
  end
2224 2224

  
2225
  def test_blocked_should_not_raise_an_exception_when_blocing_issue_is_invalid
2226
    ir = IssueRelation.find_by(issue_from_id: 10, issue_to_id: 9, relation_type: 'blocks')
2227
    issue = Issue.find(9)
2228
    assert issue.blocked?
2229

  
2230
    ir.update_column :issue_from_id, 0  # invalid issue id
2231
    issue.reload
2232
    assert !issue.blocked?
2233
  end
2234

  
2225 2235
  def test_blocked_issues_dont_allow_closed_statuses
2226 2236
    blocked_issue = Issue.find(9)
2227 2237

  
    (1-1/1)