diff options
author | Go MAEDA <maeda@farend.jp> | 2023-08-23 07:40:25 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2023-08-23 07:40:25 +0000 |
commit | 86c5d7814f4c3e860e449cdda05717984ca21405 (patch) | |
tree | 7fe0365f7b5aa4025810c0d7ee18c8aef26605e9 /test/unit/issue_test.rb | |
parent | 679ba509da39fa1537db9e5c0321d280cb44ad52 (diff) | |
download | redmine-86c5d7814f4c3e860e449cdda05717984ca21405.tar.gz redmine-86c5d7814f4c3e860e449cdda05717984ca21405.zip |
Retry in case of stale issue during Issue.update_versions (#38820).
Patch by Jens Krämer.
git-svn-id: https://svn.redmine.org/redmine/trunk@22279 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/issue_test.rb')
-rw-r--r-- | test/unit/issue_test.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index aa2ff8270..bfb35b264 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -3489,6 +3489,41 @@ class IssueTest < ActiveSupport::TestCase end end + def test_change_of_project_parent_should_update_shared_versions_with_derived_priorities + with_settings('parent_issue_priority' => 'derived') do + parent = Project.find 1 + child = Project.find 3 + assert_equal parent, child.parent + assert version = parent.versions.create(name: 'test', sharing: 'descendants') + assert version.persisted? + assert child.shared_versions.include?(version) + + # create a situation where the child issue id is lower than the parent issue id. + # When the parent project is removed, the version inherited from there will be removed from + # both issues. At least on MySQL the record with the lower Id will be processed first. + # + # If this update on the child triggers an update on the parent record (here, due to the derived + # priority), the already loaded parent issue is considered stale when it's version is updated. + assert child_issue = child.issues.first + parent_issue = Issue.create! project: child, subject: 'test', tracker: child_issue.tracker, author: child_issue.author, status: child_issue.status, fixed_version: version + assert child_issue.update fixed_version: version, priority_id: 6, parent: parent_issue + parent_issue.update_column :priority_id, 4 # force a priority update when the version is nullified + + assert child.update parent: nil + + child.reload + assert !child.shared_versions.include?(version) + + child_issue.reload + assert_nil child_issue.fixed_version + assert_equal 6, child_issue.priority_id + + parent_issue.reload + assert_nil parent_issue.fixed_version + assert_equal 6, parent_issue.priority_id + end + end + def test_create_should_not_add_anonymous_as_watcher Role.anonymous.add_permission!(:add_issue_watchers) |