diff options
author | Go MAEDA <maeda@farend.jp> | 2024-09-11 07:36:04 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2024-09-11 07:36:04 +0000 |
commit | 058b0c31ae5bfe4ed8fce5c53beca860052a1d44 (patch) | |
tree | 7689ea7cf9df3e5cf34ab98663d779fed29bc723 | |
parent | 364d9310a9e27fcbd8a74e1f9e0c4a4d7a1d8af9 (diff) | |
download | redmine-058b0c31ae5bfe4ed8fce5c53beca860052a1d44.tar.gz redmine-058b0c31ae5bfe4ed8fce5c53beca860052a1d44.zip |
Merged r23048 from trunk to 5.0-stable (#8539).
git-svn-id: https://svn.redmine.org/redmine/branches/5.0-stable@23050 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/models/issue.rb | 2 | ||||
-rw-r--r-- | test/unit/issue_test.rb | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 733e50189..d59787d40 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1015,7 +1015,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 diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 98bef8dfc..84b75be55 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -2160,6 +2160,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) |