Merged r23048 from trunk to 5.1-stable (#8539).

git-svn-id: https://svn.redmine.org/redmine/branches/5.1-stable@23049 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2024-09-11 07:32:07 +00:00
parent 6b736fe533
commit 1a70514aeb
2 changed files with 11 additions and 1 deletions

View File

@@ -1018,7 +1018,7 @@ class Issue < ActiveRecord::Base
# 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

View File

@@ -2202,6 +2202,16 @@ class IssueTest < ActiveSupport::TestCase
assert !blocking_issue.blocked?
end
def test_blocked_should_not_raise_exception_when_blocking_issue_id_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_nothing_raised {assert_not issue.blocked?}
end
def test_blocked_issues_dont_allow_closed_statuses
blocked_issue = Issue.find(9)