demarches-normaliennes/spec
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
..
controllers Merge branch 'main' into 6649-etq-usager-instructeur-rendre-la-suppression-plus-visible 2021-11-24 14:07:32 +01:00
factories Merge branch 'main' into 6649-etq-usager-instructeur-rendre-la-suppression-plus-visible 2021-11-24 14:07:32 +01:00
fixtures homogennize api particulier endpoint test url 2021-10-12 14:27:20 +02:00
helpers specs: avoid executing business logic in Procedure factory 2021-11-23 08:07:07 +01:00
jobs specs: minor cleanups 2021-11-23 08:07:07 +01:00
lib source service supports unknown scope 2021-10-12 14:27:20 +02:00
mailers specs: avoid executing business logic in Procedure factory 2021-11-23 08:07:07 +01:00
middlewares specs: always require rails_helper 2020-03-31 12:48:32 +02:00
models models: explicitely save procedure's new revision 2021-11-25 08:49:17 +01:00
policies factories: cleanup Administrateur, Instructeur and Expert factories 2021-10-26 12:03:30 +02:00
serializers specs: explicitely pass the dossier to champs factories 2021-11-23 08:07:07 +01:00
services specs: avoid executing business logic in Procedure factory 2021-11-23 08:07:07 +01:00
support feat(dossiers/show): enhance header with expirations message/banner. also ensure consistent design between dossier states 2021-11-23 05:50:25 +01:00
system Merge branch 'main' into 6649-etq-usager-instructeur-rendre-la-suppression-plus-visible 2021-11-24 14:07:32 +01:00
views Merge branch 'main' into 6649-etq-usager-instructeur-rendre-la-suppression-plus-visible 2021-11-24 14:07:32 +01:00
rails_helper.rb specs: migrate from features to system specs 2021-10-26 12:24:46 +02:00
spec_helper.rb Chore(test): enable rspec only-failures support 2021-04-15 14:17:39 +02:00