Fixed: deleting a parent issue may lead to a stale object error (#7920).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5285 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
b972b5a647
commit
6550ef9df5
|
@ -223,6 +223,16 @@ class IssueNestedSetTest < ActiveSupport::TestCase
|
||||||
assert_equal [issue1.id, 2, 3], [issue4.root_id, issue4.lft, issue4.rgt]
|
assert_equal [issue1.id, 2, 3], [issue4.root_id, issue4.lft, issue4.rgt]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_destroy_parent_issue_updated_during_children_destroy
|
||||||
|
parent = create_issue!
|
||||||
|
create_issue!(:start_date => Date.today, :parent_issue_id => parent.id)
|
||||||
|
create_issue!(:start_date => 2.days.from_now, :parent_issue_id => parent.id)
|
||||||
|
|
||||||
|
assert_difference 'Issue.count', -3 do
|
||||||
|
Issue.find(parent.id).destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_destroy_child_issue_with_children
|
def test_destroy_child_issue_with_children
|
||||||
root = Issue.create!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'root')
|
root = Issue.create!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'root')
|
||||||
child = Issue.create!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => root.id)
|
child = Issue.create!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => root.id)
|
||||||
|
|
|
@ -466,6 +466,9 @@ module CollectiveIdea #:nodoc:
|
||||||
["#{quoted_right_column_name} >= ?", right]
|
["#{quoted_right_column_name} >= ?", right]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Reload is needed because children may have updated their parent (self) during deletion.
|
||||||
|
reload
|
||||||
end
|
end
|
||||||
|
|
||||||
# reload left, right, and parent
|
# reload left, right, and parent
|
||||||
|
|
Loading…
Reference in New Issue