0005-Fix-ActiveRecord-StaleObjectError-Attempted-to-updat.patch

Marius BALTEANU, 2021-03-30 18:41

Download (3.78 KB)

View differences:

test/object_helpers.rb
105 105
  def Issue.generate!(attributes={}, &block)
106 106
    issue = Issue.generate(attributes, &block)
107 107
    issue.save!
108
    issue
108
    issue.reload
109 109
  end
110 110

  
111 111
  # Generates an issue with 2 children and a grandchild
test/unit/issue_test.rb
1440 1440
    copy = issue.reload.copy
1441 1441
    assert_difference 'Issue.count', 1+issue.descendants.count do
1442 1442
      assert copy.save
1443
      assert copy.save
1443
      assert copy.reload.save
1444 1444
    end
1445 1445
  end
1446 1446

  
......
2485 2485
    relation = new_record(IssueRelation) do
2486 2486
      copy.save!
2487 2487
    end
2488
    copy.reload
2488 2489

  
2489 2490
    copy.parent_issue_id = parent.id
2490 2491
    assert_save copy
......
2739 2740
                                     :possible_values => ['value1', 'value2', 'value3'],
2740 2741
                                     :multiple => true)
2741 2742

  
2742
    issue = Issue.create!(:project_id => 1, :tracker_id => 1,
2743
    issue = Issue.generate!(:project_id => 1, :tracker_id => 1,
2743 2744
                          :subject => 'Test', :author_id => 1)
2744 2745

  
2745 2746
    assert_difference 'Journal.count' do
test/unit/project_test.rb
245 245
  def test_destroy_should_destroy_subtasks
246 246
    issues =
247 247
      (0..2).to_a.map do
248
        Issue.create!(:project_id => 1, :tracker_id => 1,
248
        Issue.generate!(:project_id => 1, :tracker_id => 1,
249 249
                      :author_id => 1, :subject => 'test')
250 250
      end
251 251
    issues[0].update! :parent_issue_id => issues[1].id
test/unit/user_test.rb
305 305
  end
306 306

  
307 307
  def test_destroy_should_update_journals
308
    issue = Issue.create!(:project_id => 1, :author_id => 2,
308
    issue = Issue.generate!(:project_id => 1, :author_id => 2,
309 309
                          :tracker_id => 1, :subject => 'foo')
310 310
    issue.init_journal(User.find(2), "update")
311 311
    issue.save!
......
316 316
  end
317 317

  
318 318
  def test_destroy_should_update_journal_details_old_value
319
    issue = Issue.create!(:project_id => 1, :author_id => 1,
319
    issue = Issue.generate!(:project_id => 1, :author_id => 1,
320 320
                          :tracker_id => 1, :subject => 'foo', :assigned_to_id => 2)
321 321
    issue.init_journal(User.find(1), "update")
322 322
    issue.assigned_to_id = nil
......
332 332
  end
333 333

  
334 334
  def test_destroy_should_update_journal_details_value
335
    issue = Issue.create!(:project_id => 1, :author_id => 1,
335
    issue = Issue.generate!(:project_id => 1, :author_id => 1,
336 336
                          :tracker_id => 1, :subject => 'foo')
337 337
    issue.init_journal(User.find(1), "update")
338 338
    issue.assigned_to_id = 2
339
-