Actions
Patch #41881
closedImproper deletion of custom fields in IssueNestedSetConcurrencyTest causes test failures of other tests
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
- test/functional/custom_fields_controller_test.rb
- this test is for loading fixtures of custom_fields and custom_values
- 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.
- 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
Actions