Defect #41572 » 41572.patch
app/models/user.rb | ||
---|---|---|
945 | 945 |
Issue.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) |
946 | 946 |
Issue.where(['assigned_to_id = ?', id]).update_all('assigned_to_id = NULL') |
947 | 947 |
Journal.where(['user_id = ?', id]).update_all(['user_id = ?', substitute.id]) |
948 |
Journal.where(['updated_by_id = ?', id]).update_all(['updated_by_id = ?', substitute.id]) |
|
948 | 949 |
JournalDetail. |
949 | 950 |
where(["property = 'attr' AND prop_key = 'assigned_to_id' AND old_value = ?", id.to_s]). |
950 | 951 |
update_all(['old_value = ?', substitute.id.to_s]) |
test/unit/user_test.rb | ||
---|---|---|
308 | 308 |
def test_destroy_should_update_journals |
309 | 309 |
issue = Issue.generate!(:project_id => 1, :author_id => 2, |
310 | 310 |
:tracker_id => 1, :subject => 'foo') |
311 |
# Prepare a journal with both user_id and updated_by_id set to 2 |
|
311 | 312 |
issue.init_journal(User.find(2), "update") |
312 | 313 |
issue.save! |
314 |
journal = issue.journals.first |
|
315 |
journal.update_columns(updated_by_id: 2) |
|
313 | 316 | |
314 | 317 |
User.find(2).destroy |
315 | 318 |
assert_nil User.find_by_id(2) |
316 |
assert_equal User.anonymous, issue.journals.first.reload.user |
|
319 |
journal.reload |
|
320 |
assert_equal User.anonymous, journal.user |
|
321 |
assert_equal User.anonymous, journal.updated_by |
|
317 | 322 |
end |
318 | 323 | |
319 | 324 |
def test_destroy_should_update_journal_details_old_value |