demarches-normaliennes/app
Pierre de La Morinerie e5f5440663 models: explicitely save procedure's new revision
Deep-cloned objects have all their relationships stale. Thus, for a
newly deep-cloned revision, `revision.types_de_champs` returns `[]`,
even when it actually has associated types de champ.

This causes consecutive champs creations and re-ordering to fail in
subtle ways, like:

```
procedure.draft_revision.add_type_de_champ(…)
procedure.publish_revision!
procedure.draft_revision.add_type_de_champ(…)
procedure.draft_revision.move_type_de_champ(…) # this will fail
```

As `publish_revision!` created a new stale revision, moving the type
de champ fails because not all existing champs are found until the
object is refreshed.

We don't hit this path in production, because usually only a single
operation is made in a request.

To fix this, save the new revision before associating it as the draft
procedure.

(Another option would be to `reload` the revision after creation, but
this seems better contained and matches the name of the method.)
2021-11-25 08:49:17 +01:00
..
assets Merge branch 'main' into 6649-etq-usager-instructeur-rendre-la-suppression-plus-visible 2021-11-24 14:07:32 +01:00
controllers Merge branch 'main' into 6649-etq-usager-instructeur-rendre-la-suppression-plus-visible 2021-11-24 14:07:32 +01:00
dashboards manager: localize dossier enums 2021-05-06 14:41:08 +02:00
fields manager: remove support for old pj 2019-07-30 16:11:17 +02:00
graphql add cnaf type de champ 2021-10-12 14:26:40 +02:00
helpers feat(dossiers/show): enhance header with expirations message/banner. also ensure consistent design between dossier states 2021-11-23 05:50:25 +01:00
javascript fix(champs): save departement info on champ commune 2021-11-17 14:52:47 +03:00
jobs refactor(mail.delay): use simplier implementation using after_action to prevent email delivery with delay 2021-11-16 15:12:05 +01:00
lib add the good retry_on StaleObjectError 2021-11-05 13:32:21 +01:00
mailers clean(CommentaireService): extract soft delete within controller. returning an instance with an error[:base] is not persisted with validation : avoid poluting stuff 2021-11-16 16:13:11 +01:00
models models: explicitely save procedure's new revision 2021-11-25 08:49:17 +01:00
policies policies: clarify the role of ChampPolicy 2020-06-24 15:42:30 +02:00
schemas add schema validations 2021-09-22 12:08:24 +02:00
serializers modify experts avis controllers, concern and serializer 2021-03-18 11:38:52 +01:00
services manage AgentConnect callback 2021-11-23 14:17:59 +01:00
validators Add geo json validation 2021-03-11 15:51:09 +01:00
views Merge branch 'main' into 6649-etq-usager-instructeur-rendre-la-suppression-plus-visible 2021-11-24 14:07:32 +01:00