https://community.openproject.org/wp/69448
In `WorkPackages::CreateService`, the work package was saved twice:
first time at creation, second time when rescheduling related work
packages, which includes self.
Each save created a `WorkflowJob`. Normally this is ok, but if there are
mentions in the description or journal_notes, and if the two jobs are
processed in parallel (in different GoodJob threads), this leads to
having the mention notification email sent twice. Indeed, each one will
try to create the notifications and send them. The `mail_alert_sent`
flag on the notification is not set to `true` until one mail has been
sent.
To fix it, the work packages that have not been changed after
rescheduling related work packages are filtered out. This guarantees
there is only one single save in the nominal cases where there are no
related work packages that would force a second save of the work
package. Single save -> single mention notification email.
https://community.openproject.org/wp/70290
This fixes the regression introduced in 5ea185ef66: the
`possible_principal_id` was run against the source project instead of
the target project, leading to always return something.
Fix is to always run `possible_principal_id` against 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 fields nil
because the original work package has all user fields nil.
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.
* Use the default language for generating the file name of the artifact
* Update spec/services/projects/create_artifact_work_package_service_spec.rb
Co-authored-by: Mir Bhatia <m.bhatia@openproject.com>
---------
Co-authored-by: Mir Bhatia <m.bhatia@openproject.com>