Project

General

Profile

Actions

Patch #41881

closed

Improper deletion of custom fields in IssueNestedSetConcurrencyTest causes test failures of other tests

Added by Kenta Kumojima 29 days ago. Updated 28 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Testing in a particular order will fail.

$ bundle exec rails test test/functional/custom_fields_controller_test.rb:40 \
                         test/unit/issue_nested_set_concurrency_test.rb \
                         test/unit/jobs/destroy_projects_job_test.rb \
                         --seed 23861

Run options: --seed 23861

# Running:

......F

Failure:
DestroyProjectsJobTest#test_should_destroy_projects_and_send_emails [test/unit/jobs/destroy_projects_job_test.rb:53]:
"Project.count" didn't change by -6, but by -1.
Expected: 0
  Actual: 5

bin/rails test test/unit/jobs/destroy_projects_job_test.rb:52

Finished in 252.911146s, 0.0277 runs/s, 0.7552 assertions/s.
7 runs, 191 assertions, 1 failures, 0 errors, 0 skips

test.log


[ActiveJob] [DestroyProjectsJob] [61540da8-024c-4b40-ad86-bffb41965258] [DestroyProjectJob] [18ce6c70-59d9-407e-ad46-2e8f011a959b] [DestroyProjectJob] --- Error while deleting project: undefined method `f
ield_format' for nil:NilClass

            custom_values.select {|cv| cv.custom_field.field_format == 'attachment'}
                                                      ^^^^^^^^^^^^^

The reason is below

  1. test/functional/custom_fields_controller_test.rb
    • this test is for loading fixtures of custom_fields and custom_values
  2. test/unit/issue_nested_set_concurrency_test.rb
    • this test is set `self.use_transactional_tests = false` and delete custom_fields by `CustomField.delete_all`. It does not destroy custom_values. This is an invalid state.
  3. test/unit/jobs/destroy_projects_job_test.rb
    • this test is failure because of above test

This patch keeps custom fields and custom values valid by using `destroy_all` instead of `delete_all`.


Files

fix_custom_field_deleting.patch (841 Bytes) fix_custom_field_deleting.patch Kenta Kumojima, 2024-11-27 15:04
Actions

Also available in: Atom PDF