1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-05 00:23:24 +00:00

Fix "ActiveRecord::StaleObjectError: Attempted to update a stale object: Issue." (#29914, #32912).

Patch by Pavel Rosický.


git-svn-id: http://svn.redmine.org/redmine/trunk@20884 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2021-04-01 14:48:50 +00:00
parent f1b1c2f471
commit e86476eb5b
4 changed files with 8 additions and 7 deletions

View File

@ -105,7 +105,7 @@ module ObjectHelpers
def Issue.generate!(attributes={}, &block)
issue = Issue.generate(attributes, &block)
issue.save!
issue
issue.reload
end
# Generates an issue with 2 children and a grandchild

View File

@ -1440,7 +1440,7 @@ class IssueTest < ActiveSupport::TestCase
copy = issue.reload.copy
assert_difference 'Issue.count', 1+issue.descendants.count do
assert copy.save
assert copy.save
assert copy.reload.save
end
end
@ -2502,6 +2502,7 @@ class IssueTest < ActiveSupport::TestCase
relation = new_record(IssueRelation) do
copy.save!
end
copy.reload
copy.parent_issue_id = parent.id
assert_save copy
@ -2756,7 +2757,7 @@ class IssueTest < ActiveSupport::TestCase
:possible_values => ['value1', 'value2', 'value3'],
:multiple => true)
issue = Issue.create!(:project_id => 1, :tracker_id => 1,
issue = Issue.generate!(:project_id => 1, :tracker_id => 1,
:subject => 'Test', :author_id => 1)
assert_difference 'Journal.count' do

View File

@ -245,7 +245,7 @@ class ProjectTest < ActiveSupport::TestCase
def test_destroy_should_destroy_subtasks
issues =
(0..2).to_a.map do
Issue.create!(:project_id => 1, :tracker_id => 1,
Issue.generate!(:project_id => 1, :tracker_id => 1,
:author_id => 1, :subject => 'test')
end
issues[0].update! :parent_issue_id => issues[1].id

View File

@ -305,7 +305,7 @@ class UserTest < ActiveSupport::TestCase
end
def test_destroy_should_update_journals
issue = Issue.create!(:project_id => 1, :author_id => 2,
issue = Issue.generate!(:project_id => 1, :author_id => 2,
:tracker_id => 1, :subject => 'foo')
issue.init_journal(User.find(2), "update")
issue.save!
@ -316,7 +316,7 @@ class UserTest < ActiveSupport::TestCase
end
def test_destroy_should_update_journal_details_old_value
issue = Issue.create!(:project_id => 1, :author_id => 1,
issue = Issue.generate!(:project_id => 1, :author_id => 1,
:tracker_id => 1, :subject => 'foo', :assigned_to_id => 2)
issue.init_journal(User.find(1), "update")
issue.assigned_to_id = nil
@ -332,7 +332,7 @@ class UserTest < ActiveSupport::TestCase
end
def test_destroy_should_update_journal_details_value
issue = Issue.create!(:project_id => 1, :author_id => 1,
issue = Issue.generate!(:project_id => 1, :author_id => 1,
:tracker_id => 1, :subject => 'foo')
issue.init_journal(User.find(1), "update")
issue.assigned_to_id = 2