demarches-normaliennes/spec/models
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
..
champs specs: minor cleanups 2021-11-23 08:07:07 +01:00
concern refactor(repetition): optimize and add a transaction around repetition add row 2021-10-28 14:54:33 +02:00
types_de_champ add code insee libelle for commune export 2021-08-19 08:04:47 +02:00
administrateur_spec.rb factories: cleanup Administrateur, Instructeur and Expert factories 2021-10-26 12:03:30 +02:00
archive_spec.rb Revert "Revert "Export de tous les dossier d'une démarche"" 2021-04-29 17:29:47 +02:00
assign_to_spec.rb models: require belong_to associations on assign_to 2020-08-18 15:57:36 +02:00
attestation_template_spec.rb replace filter+first with find 2020-09-25 12:53:11 +00:00
avis_spec.rb experts_procedure should not be optional 2021-03-23 13:46:33 +01:00
bill_signature_spec.rb spec: use real signature to avoid mocking 2020-12-14 14:09:15 +01:00
champ_private_spec.rb specs: always require rails_helper 2020-03-31 12:48:32 +02:00
champ_shared_example.rb Improuve champ blank check 2021-07-22 10:45:25 +02:00
champ_spec.rb format phone numbers 2021-06-15 09:14:55 +02:00
commentaire_spec.rb refactor(mail.delay): use simplier implementation using after_action to prevent email delivery with delay 2021-11-16 15:12:05 +01:00
deleted_dossier_spec.rb specs: remove unused require 2021-03-25 13:24:53 +01:00
dossier_spec.rb Merge branch 'main' into 6649-etq-usager-instructeur-rendre-la-suppression-plus-visible 2021-11-24 14:07:32 +01:00
dossier_transfer_spec.rb fix(transfer): manually nullify staled transfers references 2021-10-21 13:54:26 +02:00
etablissement_spec.rb export bilans in ods and xlsx 2020-06-04 15:31:16 +02:00
exercice_spec.rb specs: always require rails_helper 2020-03-31 12:48:32 +02:00
expert_spec.rb add case when the old_expert or old_instructeur is nil 2021-10-12 11:04:06 +02:00
experts_procedure_spec.rb experts_procedure should not be optional 2021-03-23 13:46:33 +01:00
export_spec.rb Add last_month export 2021-06-23 09:23:10 +02:00
france_connect_information_spec.rb associate_user take a target email 2021-10-14 14:47:50 +02:00
france_connect_particulier_client_spec.rb specs: always require rails_helper 2020-03-31 12:48:32 +02:00
geo_area_spec.rb specs: avoid creating uneeded champs on geo_area 2021-10-26 12:03:30 +02:00
groupe_instructeur_spec.rb specs: always require rails_helper 2020-03-31 12:48:32 +02:00
individual_spec.rb models: require belong_to associations on individual 2020-08-18 15:57:37 +02:00
instructeur_spec.rb specs: minor cleanups 2021-11-23 08:07:07 +01:00
invite_spec.rb specs: always require rails_helper 2020-03-31 12:48:32 +02:00
procedure_overview_spec.rb specs: always require rails_helper 2020-03-31 12:48:32 +02:00
procedure_presentation_and_revisions_spec.rb specs: minor cleanups 2021-11-23 08:07:07 +01:00
procedure_presentation_spec.rb specs: avoid executing business logic in Procedure factory 2021-11-23 08:07:07 +01:00
procedure_revision_spec.rb fix(revisions): fix repetitions export with revisions 2021-11-03 18:20:48 +01:00
procedure_spec.rb models: explicitely save procedure's new revision 2021-11-25 08:49:17 +01:00
service_spec.rb refuse les numéros de tel invalides 2019-12-04 05:34:43 +01:00
siret_spec.rb specs: always require rails_helper 2020-03-31 12:48:32 +02:00
super_admin_spec.rb models: improve password complexity specs 2021-09-09 09:40:39 -05:00
traitement_spec.rb archives: count archived dossiers 2021-06-18 08:59:13 +02:00
trusted_device_token_spec.rb models: require belong_to associations on trusted_device_token 2020-08-18 15:57:37 +02:00
type_de_champ_private_spec.rb specs: always require rails_helper 2020-03-31 12:48:32 +02:00
type_de_champ_shared_example.rb update models specs to use revisions 2020-09-02 11:26:26 +02:00
type_de_champ_spec.rb specs: always require rails_helper 2020-03-31 12:48:32 +02:00
user_spec.rb include hidden dossier in merge 2021-11-15 23:14:41 +01:00