Defect #8539 ยป 8539.patch
| app/models/issue.rb | ||
|---|---|---|
|
# Returns true if this issue is blocked by another issue that is still open
|
||
|
def blocked?
|
||
|
!relations_to.detect {|ir| ir.relation_type == 'blocks' && !ir.issue_from.closed?}.nil?
|
||
|
relations_to.any? {|ir| ir.relation_type == 'blocks' && ir.issue_from&.closed? == false}
|
||
|
end
|
||
|
# Returns true if this issue can be closed and if not, returns false and populates the reason
|
||
| test/unit/issue_test.rb | ||
|---|---|---|
|
assert !blocking_issue.blocked?
|
||
|
end
|
||
|
def test_blocked_should_not_raise_an_exception_when_blocing_issue_is_invalid
|
||
|
ir = IssueRelation.find_by(issue_from_id: 10, issue_to_id: 9, relation_type: 'blocks')
|
||
|
issue = Issue.find(9)
|
||
|
assert issue.blocked?
|
||
|
ir.update_column :issue_from_id, 0 # invalid issue id
|
||
|
issue.reload
|
||
|
assert !issue.blocked?
|
||
|
end
|
||
|
def test_blocked_issues_dont_allow_closed_statuses
|
||
|
blocked_issue = Issue.find(9)
|
||