Feature #29914 » 0005-Fix-ActiveRecord-StaleObjectError-Attempted-to-updat.patch
| test/object_helpers.rb | ||
|---|---|---|
|
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
|
||
| test/unit/issue_test.rb | ||
|---|---|---|
|
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
|
||
| ... | ... | |
|
relation = new_record(IssueRelation) do
|
||
|
copy.save!
|
||
|
end
|
||
|
copy.reload
|
||
|
copy.parent_issue_id = parent.id
|
||
|
assert_save copy
|
||
| ... | ... | |
|
: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
|
||
| test/unit/project_test.rb | ||
|---|---|---|
|
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
|
||
| test/unit/user_test.rb | ||
|---|---|---|
|
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!
|
||
| ... | ... | |
|
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
|
||
| ... | ... | |
|
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
|
||