[70290] Project copy nilifies user fields if members are excluded #21560
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ticket
https://community.openproject.org/wp/70290
What are you trying to accomplish?
When a project is copied, and members are excluded from the copy (uncheck "Project members" in "Copy project" page), then all work packages having a user assigned should still be copied, and the user fields should be cleared.
What approach did you choose and why?
This fixes the regression introduced in 5ea185e: the
possible_principal_idwas run against the source project instead of the target project, leading to always return something.Fix is to always run
possible_principal_idagainst the target project.This was not detected by the unit tests: original tests were taking the first work package of the copied project to check that the user field was
nil, assuming the first work package would be the copy of the one having the user field set, but actually the work package was not copied, so another work package is picked and this one has all user fieldsnilbecause the original work package has all user fieldsnil.The test was fixed by explicitly getting the copied work package using the subject of the original work package, and failing if the copied work package is not found.
Merge checklist