From 1d570a40ff1eb51c2a2c7d807c742083c6cfbde6 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 26 Apr 2008 10:54:46 +0000 Subject: [PATCH] Fixed: ActiveRecord::StaleObjectError exception on closing a set of circular duplicate issues (#1105). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1360 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/issue.rb | 2 ++ test/unit/issue_test.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/models/issue.rb b/app/models/issue.rb index d6fcf53f..d6eab02f 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -153,6 +153,8 @@ class Issue < ActiveRecord::Base # Close duplicates if the issue was closed if @issue_before_change && !@issue_before_change.closed? && self.closed? duplicates.each do |duplicate| + # Reload is need in case the duplicate was updated by a previous duplicate + duplicate.reload # Don't re-close it if it's already closed next if duplicate.closed? # Same user and notes diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 7712b764..3ceba185 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -48,6 +48,8 @@ class IssueTest < Test::Unit::TestCase IssueRelation.create(:issue_from => issue1, :issue_to => issue2, :relation_type => IssueRelation::TYPE_DUPLICATES) # And 3 is a dupe of 2 IssueRelation.create(:issue_from => issue2, :issue_to => issue3, :relation_type => IssueRelation::TYPE_DUPLICATES) + # And 3 is a dupe of 1 (circular duplicates) + IssueRelation.create(:issue_from => issue1, :issue_to => issue3, :relation_type => IssueRelation::TYPE_DUPLICATES) assert issue1.reload.duplicates.include?(issue2)