diff --git a/app/assets/stylesheets/new_header.scss b/app/assets/stylesheets/new_header.scss index f3613af3f..9f87af792 100644 --- a/app/assets/stylesheets/new_header.scss +++ b/app/assets/stylesheets/new_header.scss @@ -234,6 +234,10 @@ $header-mobile-breakpoint: 550px; display: flex; color: $black; + &.active { + font-weight: bold; + } + &:hover { background: $light-grey; } diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 6e140c7c7..c1620765c 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -406,7 +406,7 @@ interface Demandeur { } """ -Une demarche +Une démarche """ type Demarche { annotationDescriptors: [ChampDescriptor!]! @@ -438,7 +438,7 @@ type Demarche { datePublication: ISO8601DateTime """ - L’état de dossier pour une démarche déclarative + Pour une démarche déclarative, état cible des dossiers à valider automatiquement """ declarative: DossierDeclarativeState @@ -551,7 +551,7 @@ type Demarche { id: ID! """ - Le numero de la démarche. + Numero de la démarche. """ number: Int! publishedRevision: Revision @@ -559,12 +559,70 @@ type Demarche { service: Service! """ - L’état de la démarche. + État de la démarche. """ state: DemarcheState! """ - Le titre de la démarche. + Titre de la démarche. + """ + title: String! +} + +""" +Une démarche (métadonnées) +Ceci est une version abrégée du type `Demarche`, qui n’expose que les métadonnées. +Cela évite l’accès récursif aux dossiers. +""" +type DemarcheDescriptor { + """ + Date de la création. + """ + dateCreation: ISO8601DateTime! + + """ + Date de la dépublication. + """ + dateDepublication: ISO8601DateTime + + """ + Date de la dernière modification. + """ + dateDerniereModification: ISO8601DateTime! + + """ + Date de la fermeture. + """ + dateFermeture: ISO8601DateTime + + """ + Date de la publication. + """ + datePublication: ISO8601DateTime + + """ + Pour une démarche déclarative, état cible des dossiers à valider automatiquement + """ + declarative: DossierDeclarativeState + + """ + Description de la démarche. + """ + description: String! + id: ID! + + """ + Numero de la démarche. + """ + number: Int! + + """ + État de la démarche. + """ + state: DemarcheState! + + """ + Titre de la démarche. """ title: String! } @@ -650,6 +708,7 @@ type Dossier { """ dateTraitement: ISO8601DateTime demandeur: Demandeur! + demarche: DemarcheDescriptor! """ L’URL du GeoJSON contenant les données cartographiques du dossier. diff --git a/app/graphql/types/demarche_descriptor_type.rb b/app/graphql/types/demarche_descriptor_type.rb new file mode 100644 index 000000000..8090f0593 --- /dev/null +++ b/app/graphql/types/demarche_descriptor_type.rb @@ -0,0 +1,24 @@ +module Types + class DemarcheDescriptorType < Types::BaseObject + description "Une démarche (métadonnées) +Ceci est une version abrégée du type `Demarche`, qui n’expose que les métadonnées. +Cela évite l’accès récursif aux dossiers." + + global_id_field :id + field :number, Int, "Numero de la démarche.", null: false, method: :id + field :title, String, "Titre de la démarche.", null: false, method: :libelle + field :description, String, "Description de la démarche.", null: false + field :state, Types::DemarcheType::DemarcheState, "État de la démarche.", null: false + field :declarative, Types::DemarcheType::DossierDeclarativeState, "Pour une démarche déclarative, état cible des dossiers à valider automatiquement", null: true, method: :declarative_with_state + + field :date_creation, GraphQL::Types::ISO8601DateTime, "Date de la création.", null: false, method: :created_at + field :date_publication, GraphQL::Types::ISO8601DateTime, "Date de la publication.", null: true, method: :published_at + field :date_derniere_modification, GraphQL::Types::ISO8601DateTime, "Date de la dernière modification.", null: false, method: :updated_at + field :date_depublication, GraphQL::Types::ISO8601DateTime, "Date de la dépublication.", null: true, method: :unpublished_at + field :date_fermeture, GraphQL::Types::ISO8601DateTime, "Date de la fermeture.", null: true, method: :closed_at + + def state + object.aasm.current_state + end + end +end diff --git a/app/graphql/types/demarche_type.rb b/app/graphql/types/demarche_type.rb index 3202fed20..4c69ea966 100644 --- a/app/graphql/types/demarche_type.rb +++ b/app/graphql/types/demarche_type.rb @@ -14,14 +14,14 @@ module Types end end - description "Une demarche" + description "Une démarche" global_id_field :id - field :number, Int, "Le numero de la démarche.", null: false, method: :id - field :title, String, "Le titre de la démarche.", null: false, method: :libelle + field :number, Int, "Numero de la démarche.", null: false, method: :id + field :title, String, "Titre de la démarche.", null: false, method: :libelle field :description, String, "Description de la démarche.", null: false - field :state, DemarcheState, "L’état de la démarche.", null: false - field :declarative, DossierDeclarativeState, "L’état de dossier pour une démarche déclarative", null: true, method: :declarative_with_state + field :state, DemarcheState, "État de la démarche.", null: false + field :declarative, DossierDeclarativeState, "Pour une démarche déclarative, état cible des dossiers à valider automatiquement", null: true, method: :declarative_with_state field :date_creation, GraphQL::Types::ISO8601DateTime, "Date de la création.", null: false, method: :created_at field :date_publication, GraphQL::Types::ISO8601DateTime, "Date de la publication.", null: true, method: :published_at diff --git a/app/graphql/types/dossier_type.rb b/app/graphql/types/dossier_type.rb index 3e9ecec5a..16e08aff1 100644 --- a/app/graphql/types/dossier_type.rb +++ b/app/graphql/types/dossier_type.rb @@ -12,6 +12,8 @@ module Types field :number, Int, "Le numero du dossier.", null: false, method: :id field :state, DossierState, "L’état du dossier.", null: false + field :demarche, Types::DemarcheDescriptorType, null: false, method: :procedure + field :date_passage_en_construction, GraphQL::Types::ISO8601DateTime, "Date de dépôt.", null: false, method: :en_construction_at field :date_passage_en_instruction, GraphQL::Types::ISO8601DateTime, "Date de passage en instruction.", null: true, method: :en_instruction_at field :date_traitement, GraphQL::Types::ISO8601DateTime, "Date de traitement.", null: true, method: :processed_at diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 902dada56..3a1958cb3 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -57,7 +57,7 @@ class Dossier < ApplicationRecord REMAINING_DAYS_BEFORE_CLOSING = 2 INTERVAL_BEFORE_CLOSING = "#{REMAINING_DAYS_BEFORE_CLOSING} days" - INTERVAL_BEFORE_EXPIRATION = '1 month' + INTERVAL_BEFORE_EXPIRATION = '2 weeks' INTERVAL_EXPIRATION = '1 month 5 days' has_one :etablissement, dependent: :destroy diff --git a/app/views/devise_mailer/confirmation_instructions.en.html.haml b/app/views/devise_mailer/confirmation_instructions.en.html.haml new file mode 100644 index 000000000..7f5d3c3db --- /dev/null +++ b/app/views/devise_mailer/confirmation_instructions.en.html.haml @@ -0,0 +1,21 @@ +-# ugly hack to know if the mail is creation confirmation or a password change confirmation +- if @user.unconfirmed_email.nil? + - content_for(:title, 'Activate account') + + %p= t(:hello, scope: [:views, :shared, :greetings]) + + %p + You have entered your details to create an account on #{APPLICATION_NAME}. To confirm your email and finish creating your account, select the following link: + - link = confirmation_url(@user, confirmation_token: @token, procedure_id: @procedure&.id) + = link_to(link, link) + +- else + - content_for(:title, "Change email address") + + %p= t(:hello, scope: [:views, :shared, :greetings]) + + %p + To confirm your account email change on #{APPLICATION_NAME}, select the following link: + = link_to(confirmation_url(@user, confirmation_token: @token), confirmation_url(@user, confirmation_token: @token)) + += render partial: "layouts/mailers/signature" diff --git a/app/views/devise_mailer/confirmation_instructions.html.haml b/app/views/devise_mailer/confirmation_instructions.html.haml index 25710acc4..cab00c327 100644 --- a/app/views/devise_mailer/confirmation_instructions.html.haml +++ b/app/views/devise_mailer/confirmation_instructions.html.haml @@ -2,8 +2,7 @@ - if @user.unconfirmed_email.nil? - content_for(:title, 'Activez votre compte') - %p - Bonjour, + %p= t(:hello, scope: [:views, :shared, :greetings]) %p Pour activer votre compte sur #{APPLICATION_NAME}, veuillez cliquer sur le lien suivant : @@ -13,8 +12,7 @@ - else - content_for(:title, "Changement d’adresse email") - %p - Bonjour, + %p= t(:hello, scope: [:views, :shared, :greetings]) %p Pour confirmer votre changement d’adresse email, veuillez cliquer sur le lien suivant : diff --git a/app/views/devise_mailer/email_changed.en.html.haml b/app/views/devise_mailer/email_changed.en.html.haml new file mode 100644 index 000000000..4371b4709 --- /dev/null +++ b/app/views/devise_mailer/email_changed.en.html.haml @@ -0,0 +1,13 @@ +- content_for(:title, 'New email address') + +%p= t(:hello, scope: [:views, :shared, :greetings]) + +- unconfirmed_email = @resource.try(:unconfirmed_email?) +- if unconfirmed_email.present? + %p + We recieved a request to change the email address associated with your account #{@email} on #{APPLICATION_NAME}. The new email address will be #{unconfirmed_email}. +- else + %p + A change to the email address associated with your account #{@email} was made on #{APPLICATION_NAME}. You can now connect with the email address #{@resource.email}. + += render partial: "layouts/mailers/signature" diff --git a/app/views/devise_mailer/email_changed.html.haml b/app/views/devise_mailer/email_changed.html.haml index e8db96fe0..04fc96449 100644 --- a/app/views/devise_mailer/email_changed.html.haml +++ b/app/views/devise_mailer/email_changed.html.haml @@ -1,7 +1,6 @@ - content_for(:title, 'Votre nouvelle adresse email') -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) - unconfirmed_email = @resource.try(:unconfirmed_email?) - if unconfirmed_email.present? diff --git a/app/views/devise_mailer/password_change.en.html.haml b/app/views/devise_mailer/password_change.en.html.haml new file mode 100644 index 000000000..3f5acd006 --- /dev/null +++ b/app/views/devise_mailer/password_change.en.html.haml @@ -0,0 +1,8 @@ +- content_for(:title, 'New password') + +%p= t(:hello, scope: [:views, :shared, :greetings]) + +%p + A request to change your password on #{APPLICATION_NAME} for the account #{@resource.email} was successfully processed. + += render partial: "layouts/mailers/signature" diff --git a/app/views/devise_mailer/password_change.html.haml b/app/views/devise_mailer/password_change.html.haml index 02c297634..56403e9fd 100644 --- a/app/views/devise_mailer/password_change.html.haml +++ b/app/views/devise_mailer/password_change.html.haml @@ -1,7 +1,6 @@ - content_for(:title, 'Votre nouveau mot de passe') -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p La demande de changement de mot de passe pour votre compte #{@resource.email} sur diff --git a/app/views/devise_mailer/reset_password_instructions.en.html.haml b/app/views/devise_mailer/reset_password_instructions.en.html.haml new file mode 100644 index 000000000..d5eb8744a --- /dev/null +++ b/app/views/devise_mailer/reset_password_instructions.en.html.haml @@ -0,0 +1,11 @@ +%p= t(:hello, scope: [:views, :shared, :greetings]) + +%p + Someone has requested to change your account password on #{APPLICATION_NAME}. To define a new password, select the following link: + += round_button 'Change the password', edit_password_url(@resource, reset_password_token: @token), :primary + +%p + If you didn't request this, please ignore this email. Your password won't change. + += render partial: "layouts/mailers/signature" diff --git a/app/views/devise_mailer/reset_password_instructions.html.haml b/app/views/devise_mailer/reset_password_instructions.html.haml index 051a5d054..c4cfd37aa 100644 --- a/app/views/devise_mailer/reset_password_instructions.html.haml +++ b/app/views/devise_mailer/reset_password_instructions.html.haml @@ -1,5 +1,4 @@ -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p Vous avez demandé à changer votre mot de passe sur #{APPLICATION_NAME}. Pour ceci, merci de cliquer sur le lien suivant : diff --git a/app/views/devise_mailer/unlock_instructions.en.html.haml b/app/views/devise_mailer/unlock_instructions.en.html.haml new file mode 100644 index 000000000..acdde6627 --- /dev/null +++ b/app/views/devise_mailer/unlock_instructions.en.html.haml @@ -0,0 +1,14 @@ +- content_for(:title, 'Reactivate account') + +%p= t(:hello, scope: [:views, :shared, :greetings]) + +%p + Someone made too many unsuccessful attempts to connect to your account #{@resource.email} on #{APPLICATION_NAME}. + As a security measure, we temporarily locked access to your account. + +%p + To unlock access to your account, select the following link: + +%p= link_to 'Unlock account', unlock_url(@resource, unlock_token: @token) + += render partial: "layouts/mailers/signature" diff --git a/app/views/devise_mailer/unlock_instructions.html.haml b/app/views/devise_mailer/unlock_instructions.html.haml index 123009049..3fa534fc4 100644 --- a/app/views/devise_mailer/unlock_instructions.html.haml +++ b/app/views/devise_mailer/unlock_instructions.html.haml @@ -1,7 +1,6 @@ - content_for(:title, 'Réactivez votre compte') -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p Quelqu’un a tenté de se connecter un grand nombre de fois sans succès à votre diff --git a/app/views/dossier_mailer/notify_automatic_deletion_to_administration.html.haml b/app/views/dossier_mailer/notify_automatic_deletion_to_administration.html.haml index 373b78d11..286f30134 100644 --- a/app/views/dossier_mailer/notify_automatic_deletion_to_administration.html.haml +++ b/app/views/dossier_mailer/notify_automatic_deletion_to_administration.html.haml @@ -1,7 +1,6 @@ - content_for(:title, "#{@subject}") -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p = t('.header', count: @deleted_dossiers.count) diff --git a/app/views/dossier_mailer/notify_automatic_deletion_to_user.html.haml b/app/views/dossier_mailer/notify_automatic_deletion_to_user.html.haml index bf35cabe2..afbfc3fac 100644 --- a/app/views/dossier_mailer/notify_automatic_deletion_to_user.html.haml +++ b/app/views/dossier_mailer/notify_automatic_deletion_to_user.html.haml @@ -1,7 +1,6 @@ - content_for(:title, "#{@subject}") -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p = t('.header', count: @deleted_dossiers.count) diff --git a/app/views/dossier_mailer/notify_brouillon_deletion.html.haml b/app/views/dossier_mailer/notify_brouillon_deletion.html.haml index a621b7009..4461c9c98 100644 --- a/app/views/dossier_mailer/notify_brouillon_deletion.html.haml +++ b/app/views/dossier_mailer/notify_brouillon_deletion.html.haml @@ -1,7 +1,6 @@ - content_for(:title, "#{@subject}") -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p = t('.header', count: @dossier_hashes.count) diff --git a/app/views/dossier_mailer/notify_brouillon_near_deletion.html.haml b/app/views/dossier_mailer/notify_brouillon_near_deletion.html.haml index bce0ad8dc..450abf898 100644 --- a/app/views/dossier_mailer/notify_brouillon_near_deletion.html.haml +++ b/app/views/dossier_mailer/notify_brouillon_near_deletion.html.haml @@ -1,7 +1,6 @@ - content_for(:title, "#{@subject}") -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p = t('.header', count: @dossiers.count) diff --git a/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml b/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml index dfc1f4610..b4a62cfed 100644 --- a/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml +++ b/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml @@ -1,7 +1,6 @@ - content_for(:title, "#{@subject}") -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p Le dossier n°#{@dossier.id} pour la démarche «  diff --git a/app/views/dossier_mailer/notify_deletion_to_administration.html.haml b/app/views/dossier_mailer/notify_deletion_to_administration.html.haml index e64cab4b6..55da5cfe9 100644 --- a/app/views/dossier_mailer/notify_deletion_to_administration.html.haml +++ b/app/views/dossier_mailer/notify_deletion_to_administration.html.haml @@ -1,7 +1,6 @@ - content_for(:title, "#{@subject}") -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p = t('.body', dossier_id: @deleted_dossier.dossier_id, procedure: @deleted_dossier.procedure.libelle) diff --git a/app/views/dossier_mailer/notify_deletion_to_user.html.haml b/app/views/dossier_mailer/notify_deletion_to_user.html.haml index e64cab4b6..55da5cfe9 100644 --- a/app/views/dossier_mailer/notify_deletion_to_user.html.haml +++ b/app/views/dossier_mailer/notify_deletion_to_user.html.haml @@ -1,7 +1,6 @@ - content_for(:title, "#{@subject}") -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p = t('.body', dossier_id: @deleted_dossier.dossier_id, procedure: @deleted_dossier.procedure.libelle) diff --git a/app/views/dossier_mailer/notify_groupe_instructeur_changed.html.haml b/app/views/dossier_mailer/notify_groupe_instructeur_changed.html.haml index f87c675f9..c45087d0f 100644 --- a/app/views/dossier_mailer/notify_groupe_instructeur_changed.html.haml +++ b/app/views/dossier_mailer/notify_groupe_instructeur_changed.html.haml @@ -1,5 +1,7 @@ - content_for(:title, "#{@subject}") +%p= t(:hello, scope: [:views, :shared, :greetings]) + %p = "Vous suiviez jusqu'à maintenant le dossier n°#{@dossier_id} de la démarche #{@demarche}." L’usager a modifié le groupe de routage. Son dossier appartient maintenant à un groupe instructeur dont vous ne faites pas partie. diff --git a/app/views/dossier_mailer/notify_instructeur_deletion_to_user.html.haml b/app/views/dossier_mailer/notify_instructeur_deletion_to_user.html.haml index 0dde82206..f1959341f 100644 --- a/app/views/dossier_mailer/notify_instructeur_deletion_to_user.html.haml +++ b/app/views/dossier_mailer/notify_instructeur_deletion_to_user.html.haml @@ -1,7 +1,6 @@ - content_for(:title, "#{@subject}") -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p = t('.body_html', dossier_id: @deleted_dossier.dossier_id, libelle_demarche: @deleted_dossier.procedure.libelle, deleted_dossiers_link: dossiers_url(statut: 'dossiers-supprimes')) diff --git a/app/views/dossier_mailer/notify_near_deletion_to_administration.html.haml b/app/views/dossier_mailer/notify_near_deletion_to_administration.html.haml index 485757f6d..ff752e469 100644 --- a/app/views/dossier_mailer/notify_near_deletion_to_administration.html.haml +++ b/app/views/dossier_mailer/notify_near_deletion_to_administration.html.haml @@ -1,7 +1,6 @@ - content_for(:title, "#{@subject}") -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p - if @state == Dossier.states.fetch(:en_construction) diff --git a/app/views/dossier_mailer/notify_near_deletion_to_user.html.haml b/app/views/dossier_mailer/notify_near_deletion_to_user.html.haml index a4af7f504..d888955fe 100644 --- a/app/views/dossier_mailer/notify_near_deletion_to_user.html.haml +++ b/app/views/dossier_mailer/notify_near_deletion_to_user.html.haml @@ -1,7 +1,6 @@ - content_for(:title, "#{@subject}") -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p - if @state == Dossier.states.fetch(:en_construction) diff --git a/app/views/dossier_mailer/notify_new_answer.en.html.haml b/app/views/dossier_mailer/notify_new_answer.en.html.haml new file mode 100644 index 000000000..88ef43b79 --- /dev/null +++ b/app/views/dossier_mailer/notify_new_answer.en.html.haml @@ -0,0 +1,31 @@ +- content_for :procedure_logo do + = render 'layouts/mailers/logo', url: @logo_url + +%p= t(:hello, scope: [:views, :shared, :greetings]) + +- if !@dossier.brouillon? + %p + You received + %strong a new message + from the service in charge of examine your File. + %p + To read the message and answer it, select the following link: + + = round_button('Read the message', messagerie_dossier_url(@dossier), :primary) +- else + %p + You received + %strong a new message + from the service in charge of examine the File you started a draft for on the procedure #{@dossier.procedure.libelle}. + %p{ style: "padding: 8px; color: #333333; background-color: #EEEEEE; font-size: 14px;" } + = @body + + %p + If you chose to contact the service, please use the email available below in the page. + + = round_button('Open the File', dossier_url(@dossier), :primary) + += render 'layouts/mailers/signature', service: @service + +- content_for :footer do + = render 'layouts/mailers/service_footer', service: @service, dossier: @dossier diff --git a/app/views/dossier_mailer/notify_new_answer.html.haml b/app/views/dossier_mailer/notify_new_answer.html.haml index de623db62..932b6e4f1 100644 --- a/app/views/dossier_mailer/notify_new_answer.html.haml +++ b/app/views/dossier_mailer/notify_new_answer.html.haml @@ -1,8 +1,7 @@ - content_for :procedure_logo do = render 'layouts/mailers/logo', url: @logo_url -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) - if !@dossier.brouillon? %p diff --git a/app/views/dossier_mailer/notify_new_commentaire_to_instructeur.html.haml b/app/views/dossier_mailer/notify_new_commentaire_to_instructeur.html.haml index cfb294aa6..4f5b6346f 100644 --- a/app/views/dossier_mailer/notify_new_commentaire_to_instructeur.html.haml +++ b/app/views/dossier_mailer/notify_new_commentaire_to_instructeur.html.haml @@ -1,7 +1,6 @@ - content_for(:title, "#{@subject}") -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p = t('.body', dossier_id: @dossier.id, libelle_demarche: @dossier.procedure.libelle) diff --git a/app/views/dossier_mailer/notify_new_dossier_depose_to_instructeur.html.haml b/app/views/dossier_mailer/notify_new_dossier_depose_to_instructeur.html.haml index 1d05aa596..7363bd1ea 100644 --- a/app/views/dossier_mailer/notify_new_dossier_depose_to_instructeur.html.haml +++ b/app/views/dossier_mailer/notify_new_dossier_depose_to_instructeur.html.haml @@ -1,7 +1,6 @@ - content_for(:title, "#{@subject}") -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p = t('.body', dossier_id: @dossier.id, libelle_demarche: @dossier.procedure.libelle) diff --git a/app/views/dossier_mailer/notify_new_draft.en.html.haml b/app/views/dossier_mailer/notify_new_draft.en.html.haml new file mode 100644 index 000000000..2c6e001b3 --- /dev/null +++ b/app/views/dossier_mailer/notify_new_draft.en.html.haml @@ -0,0 +1,23 @@ +- content_for :procedure_logo do + = render 'layouts/mailers/logo', url: @logo_url + +%p= t(:hello, scope: [:views, :shared, :greetings]) + +%p + You started filling a File on the procedure: + = succeed '.' do + %strong « #{@dossier.procedure.libelle} » + +%p + You can access your File, to review or complete, by clicking on the following button: + += round_button('Access your File', dossier_url(@dossier), :primary) + +- if @dossier.procedure.auto_archive_on + %p + Your File needs to be submitted before #{procedure_auto_archive_datetime(@dossier.procedure)}. + += render 'layouts/mailers/signature' + +- content_for :footer do + = render 'layouts/mailers/service_footer', service: @service, dossier: @dossier diff --git a/app/views/dossier_mailer/notify_new_draft.html.haml b/app/views/dossier_mailer/notify_new_draft.html.haml index 4553738bf..fdb341967 100644 --- a/app/views/dossier_mailer/notify_new_draft.html.haml +++ b/app/views/dossier_mailer/notify_new_draft.html.haml @@ -1,8 +1,7 @@ - content_for :procedure_logo do = render 'layouts/mailers/logo', url: @logo_url -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p Vous avez commencé à remplir un dossier pour la démarche diff --git a/app/views/dossier_mailer/notify_revert_to_instruction.en.html.haml b/app/views/dossier_mailer/notify_revert_to_instruction.en.html.haml new file mode 100644 index 000000000..2f64e85ae --- /dev/null +++ b/app/views/dossier_mailer/notify_revert_to_instruction.en.html.haml @@ -0,0 +1,21 @@ +- content_for :procedure_logo do + = render 'layouts/mailers/logo', url: @logo_url + +%p= t(:hello, scope: [:views, :shared, :greetings]) + +%p + Your File will be reexamined. All previous decisions are void. + To see the File created on procedure + %strong= @dossier.procedure.libelle + , select the following link: + = link_to dossier_url(@dossier), dossier_url(@dossier), target: '_blank', rel: 'noopener' + +- if @dossier.procedure.service.present? + %p + In order to get more details about the decision to reexamin, please contact the following service: + = mail_to @dossier.procedure.service.email, @dossier.procedure.service.email + += render 'layouts/mailers/signature' + +- content_for :footer do + = render 'layouts/mailers/service_footer', service: @service, dossier: @dossier diff --git a/app/views/dossier_mailer/notify_revert_to_instruction.html.haml b/app/views/dossier_mailer/notify_revert_to_instruction.html.haml index f5b8caa5e..0f75d8070 100644 --- a/app/views/dossier_mailer/notify_revert_to_instruction.html.haml +++ b/app/views/dossier_mailer/notify_revert_to_instruction.html.haml @@ -1,8 +1,7 @@ - content_for :procedure_logo do = render 'layouts/mailers/logo', url: @logo_url -%p - Bonjour, +%p= t(:hello, scope: [:views, :shared, :greetings]) %p Votre dossier va être réexaminé, la précédente décision sur ce dossier est caduque. diff --git a/app/views/layouts/_locale_dropdown.html.haml b/app/views/layouts/_locale_dropdown.html.haml index 7198b8f5e..15ef75f61 100644 --- a/app/views/layouts/_locale_dropdown.html.haml +++ b/app/views/layouts/_locale_dropdown.html.haml @@ -1,11 +1,11 @@ .dropdown.locale-dropdown.header-menu-opener - %button.button.dropdown-button.icon-only.header-menu-button{ title: "Translate", aria: { expanded: 'false', controls: 'locale_menu' } } - .hidden Translate - = image_tag "icons/translate-icon.svg", alt: 'Translate', width: 24, height: 24, lazy: true, aria: { hidden: true } + %button.button.dropdown-button.icon-only.header-menu-button{ title: t('.languages'), aria: { expanded: 'false', controls: 'locale_menu' } } + .hidden t('.languages') + = image_tag "icons/translate-icon.svg", alt: t('.languages'), width: 24, height: 24, lazy: true, aria: { hidden: true } %ul.header-menu.dropdown-content %li - = link_to save_locale_path(locale: :en), method: :post, class: "menu-item menu-link" do - EN – English + = active_link_to save_locale_path(locale: :fr), method: :post, class: "menu-item menu-link", active: I18n.locale == :fr do + Français %li - = link_to save_locale_path(locale: :fr), method: :post, class: "menu-item menu-link" do - FR – français + = active_link_to save_locale_path(locale: :en), method: :post, class: "menu-item menu-link", active: I18n.locale == :en do + English diff --git a/app/views/layouts/commencer/_no_procedure.html.haml b/app/views/layouts/commencer/_no_procedure.html.haml index 971726f97..50037d4ad 100644 --- a/app/views/layouts/commencer/_no_procedure.html.haml +++ b/app/views/layouts/commencer/_no_procedure.html.haml @@ -2,8 +2,8 @@ = image_tag "landing/hero/dematerialiser.svg", class: "paperless-logo", alt: "moins de papier" .baseline.center %p - %span.simple= t('views.layouts.commencer.no_procedure.line1') + %span.simple= t('.line1') %br - = t('views.layouts.commencer.no_procedure.line2') + = t('.line2') %br - = t('views.layouts.commencer.no_procedure.line3') + = t('.line3') diff --git a/app/views/layouts/mailers/_signature.html.haml b/app/views/layouts/mailers/_signature.html.haml index 985288c7b..c26f14396 100644 --- a/app/views/layouts/mailers/_signature.html.haml +++ b/app/views/layouts/mailers/_signature.html.haml @@ -1,5 +1,5 @@ %p - Bonne journée, + = t(:best_regards, scope: [:views, :shared, :greetings]) %br - if defined?(service) && service && service.nom.present? = service.nom diff --git a/app/views/notification_mailer/_actions.html.haml b/app/views/notification_mailer/_actions.html.haml index 7bf754962..339fce65b 100644 --- a/app/views/notification_mailer/_actions.html.haml +++ b/app/views/notification_mailer/_actions.html.haml @@ -4,10 +4,10 @@ - variant = (index == 0 ? :primary : :secondary) - case action - when MailTemplateConcern::Actions::SHOW - = round_button('Consulter mon dossier', dossier_url(@dossier), variant) + = round_button(t(:access, scope: [:layouts, :notifications, :actions]), dossier_url(@dossier), variant) - when MailTemplateConcern::Actions::ASK_QUESTION - = round_button('J’ai une question', messagerie_dossier_url(@dossier), variant) + = round_button(t(:question, scope: [:layouts, :notifications, :actions]), messagerie_dossier_url(@dossier), variant) - when MailTemplateConcern::Actions::REPLY - = round_button('Répondre à ce message', messagerie_dossier_url(@dossier), variant) + = round_button(t(:reply, scope: [:layouts, :notifications, :actions]), messagerie_dossier_url(@dossier), variant) = vertical_margin(5) diff --git a/app/views/users/passwords/new.html.haml b/app/views/users/passwords/new.html.haml index 5513f1890..ec02b04e2 100644 --- a/app/views/users/passwords/new.html.haml +++ b/app/views/users/passwords/new.html.haml @@ -11,9 +11,9 @@ %h1= t('devise.passwords.new.forgot_your_password') - %p.notice= t('views.passwords.new.send_me_reset_password_instructions') + %p.notice= t('devise.passwords.new.send_me_reset_password_instructions') = f.label :email, 'Email' = f.email_field :email, autofocus: true - = f.submit 'Demander un nouveau mot de passe', class: 'button expand primary' + = f.submit t('devise.passwords.new.request_new_password'), class: 'button expand primary' diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml new file mode 100644 index 000000000..9a8aea664 --- /dev/null +++ b/config/locales/devise.en.yml @@ -0,0 +1,5 @@ +en: + devise: + passwords: + new: + request_new_password: Request new password diff --git a/config/locales/devise.fr.yml b/config/locales/devise.fr.yml new file mode 100644 index 000000000..098f3e3f3 --- /dev/null +++ b/config/locales/devise.fr.yml @@ -0,0 +1,5 @@ +fr: + devise: + passwords: + new: + request_new_password: Demander un nouveau mot de passe diff --git a/config/locales/en.yml b/config/locales/en.yml index 79733ad87..17244f9b8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -45,6 +45,19 @@ en: commentaire: send_message_to_instructeur: "Send a message to the instructor" reply_in_mailbox: "Reply in mailbox" + layouts: + commencer: + no_procedure: + line1: A simple tool + line2: to manage dematerialized + line3: administrative forms. + locale_dropdown: + languages: "Languages" + notifications: + actions: + access: View your File + question: I have a question + reply: Reply to this message views: commencer: show: @@ -85,12 +98,6 @@ en: want_to_withdraw_permission: "Would you like to withdraw the permission?" edit_dossier: "These people can edit this file." submit_dossier_yourself: "You must submit the file yourself when it is complete." - layouts: - commencer: - no_procedure: - line1: A simple tool - line2: to manage dematerialized - line3: administrative forms. pagination: next: Next last: Last @@ -98,6 +105,9 @@ en: first: First truncate: '…' shared: + greetings: + hello: Dear Sir or Madam, + best_regards: Best Regards, dossiers: edit: autosave: Your file is automatically saved after each modification. You can close the window at any time and pick up where you left off later. diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 6e1b0fdf9..4d8bc3e5a 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -35,6 +35,20 @@ fr: commentaire: send_message_to_instructeur: "Envoyer un message à l’instructeur" reply_in_mailbox: "Répondre dans la messagerie." + layouts: + commencer: + no_procedure: + line1: Un outil simple + line2: pour gérer les formulaires + line3: administratifs dématérialisés. + locale_dropdown: + languages: "Langues" + notifications: + actions: + access: Consulter mon dossier + question: J’ai une question + reply: Répondre à ce message + views: commencer: show: @@ -76,12 +90,6 @@ fr: want_to_withdraw_permission: "Souhaitez-vous supprimer l’autorisation ?" edit_dossier: "Ces personnes peuvent modifier ce dossier." submit_dossier_yourself: "Une fois le dossier complet, vous devez le déposer vous-même." - layouts: - commencer: - no_procedure: - line1: Un outil simple - line2: pour gérer les formulaires - line3: administratifs dématérialisés. pagination: next: Suivant last: Dernier @@ -89,6 +97,9 @@ fr: first: Premier truncate: '…' shared: + greetings: + hello: Bonjour, + best_regards: Bonne journée, dossiers: edit: autosave: Votre dossier est enregistré automatiquement après chaque modification. Vous pouvez à tout moment fermer la fenêtre et reprendre plus tard là où vous en étiez. diff --git a/config/locales/views/dossier_mailer/notify_near_deletion_to_administration/fr.yml b/config/locales/views/dossier_mailer/notify_near_deletion_to_administration/fr.yml index c1bd54250..6e679332f 100644 --- a/config/locales/views/dossier_mailer/notify_near_deletion_to_administration/fr.yml +++ b/config/locales/views/dossier_mailer/notify_near_deletion_to_administration/fr.yml @@ -14,8 +14,8 @@ fr: one: "Le dossier suivant dont le traitement est terminé sera bientôt automatiquement supprimé :" other: "Les dossiers suivant dont le traitement est terminé seront bientôt automatiquement supprimés :" footer_en_construction: - one: "Vous avez un mois pour commencer l’instruction du dossier." - other: "Vous avez un mois pour commencer l’instruction des dossiers." + one: "Vous avez deux semaines pour commencer l’instruction du dossier." + other: "Vous avez deux semaines pour commencer l’instruction des dossiers." footer_termine: - one: "Vous avez un mois pour archiver le dossier." - other: "Vous avez un mois pour archiver les dossiers." + one: "Vous avez deux semaines pour archiver le dossier." + other: "Vous avez deux semaines pour archiver les dossiers." diff --git a/config/locales/views/dossier_mailer/notify_near_deletion_to_user/fr.yml b/config/locales/views/dossier_mailer/notify_near_deletion_to_user/fr.yml index f168c63dc..32b3aa810 100644 --- a/config/locales/views/dossier_mailer/notify_near_deletion_to_user/fr.yml +++ b/config/locales/views/dossier_mailer/notify_near_deletion_to_user/fr.yml @@ -14,8 +14,8 @@ fr: one: "Afin de limiter la conservation de vos données personnelles, le dossier suivant dont le traitement est terminé sera bientôt automatiquement supprimé :" other: "Afin de limiter la conservation de vos données personnelles, les dossiers suivant dont le traitement est terminé seront bientôt automatiquement supprimés :" footer: - one: "Vous pouvez retrouver votre dossier pendant encore un mois. Vous n’avez rien à faire." - other: "Vous pouvez retrouver vos dossiers pendant encore un mois. Vous n’avez rien à faire." + one: "Vous pouvez retrouver votre dossier pendant encore deux semaines. Vous n’avez rien à faire." + other: "Vous pouvez retrouver vos dossiers pendant encore deux semaines. Vous n’avez rien à faire." footer_en_construction: one: "Si vous souhaitez conserver votre dossier plus longtemps, vous pouvez prolonger sa durée de conservation dans l’interface." other: "Si vous souhaitez conserver vos dossiers plus longtemps, vous pouvez prolonger leur durée de conservation au cas par cas dans l’interface." diff --git a/lib/tasks/deployment/20210720133539_remove_migration_status_on_filters.rake b/lib/tasks/deployment/20210720133539_remove_migration_status_on_filters.rake new file mode 100644 index 000000000..897a564f8 --- /dev/null +++ b/lib/tasks/deployment/20210720133539_remove_migration_status_on_filters.rake @@ -0,0 +1,24 @@ +namespace :after_party do + desc 'Deployment task: remove_migration_status_on_filters' + task remove_migration_status_on_filters: :environment do + rake_puts "Running deploy task 'remove_migration_status_on_filters'" + + # In a9a4f6e2a801b19b127aae8eaec0d1f384b1a53a, a task to migrate ProcedurePresentation's filters + # was added. + # This task added a "migrated: true" key to all migrated filters. + # + # Now that this task has run, we can safely remove the extra key. + + procedure_presentations = ProcedurePresentation.where("filters -> 'migrated' IS NOT NULL") + progress = ProgressReport.new(procedure_presentations.count) + + procedure_presentations.find_each do |pp| + pp.update_column(:filters, pp.filters.except('migrated')) + progress.inc + end + progress.finish + + AfterParty::TaskRecord + .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp + end +end diff --git a/lib/tasks/task_helper.rb b/lib/tasks/task_helper.rb index ef6a0bd95..8323773d7 100644 --- a/lib/tasks/task_helper.rb +++ b/lib/tasks/task_helper.rb @@ -15,6 +15,17 @@ def rake_print(*args) end end +# Display progress of a long-running Rake task. +# +# Usage: +# +# ``` +# progress = ProgressReport.new(100) +# (0..100).times do +# progress.inc +# end +# progress.finish +# ```` class ProgressReport def initialize(total) @start = Time.zone.now diff --git a/spec/controllers/api/v2/graphql_controller_spec.rb b/spec/controllers/api/v2/graphql_controller_spec.rb index ee0bf80b4..831786fb5 100644 --- a/spec/controllers/api/v2/graphql_controller_spec.rb +++ b/spec/controllers/api/v2/graphql_controller_spec.rb @@ -310,6 +310,11 @@ describe API::V2::GraphqlController do motivationAttachment { url } + demarche { + number + title + state + } usager { id email @@ -382,6 +387,11 @@ describe API::V2::GraphqlController do dateTraitement: nil, motivation: nil, motivationAttachment: nil, + demarche: { + number: dossier.procedure.id, + title: dossier.procedure.libelle, + state: 'publiee' + }, usager: { id: dossier.user.to_typed_id, email: dossier.user.email diff --git a/spec/controllers/manager/administrateurs_controller_spec.rb b/spec/controllers/manager/administrateurs_controller_spec.rb index ebd41fe36..58f0f4877 100644 --- a/spec/controllers/manager/administrateurs_controller_spec.rb +++ b/spec/controllers/manager/administrateurs_controller_spec.rb @@ -1,4 +1,4 @@ -xdescribe Manager::AdministrateursController, type: :controller do +describe Manager::AdministrateursController, type: :controller do let(:super_admin) { create(:super_admin) } let(:administrateur) { create(:administrateur) } diff --git a/spec/features/i18n_spec.rb b/spec/features/i18n_spec.rb index cfe40915b..0c372a0cd 100644 --- a/spec/features/i18n_spec.rb +++ b/spec/features/i18n_spec.rb @@ -7,8 +7,8 @@ feature 'Accessing the website in different languages:' do visit new_user_session_path expect(page).to have_text('Connectez-vous') - click_on 'Translate' - click_on 'EN – English' + click_on 'Langues' + click_on 'English' # The page is now in English expect(page).to have_text('Sign in') diff --git a/spec/lib/tasks/deployment/20210720133539_remove_migration_status_on_filters_spec.rb b/spec/lib/tasks/deployment/20210720133539_remove_migration_status_on_filters_spec.rb new file mode 100644 index 000000000..17828822d --- /dev/null +++ b/spec/lib/tasks/deployment/20210720133539_remove_migration_status_on_filters_spec.rb @@ -0,0 +1,68 @@ +describe '20201001161931_migrate_filters_to_use_stable_id' do + let(:rake_task) { Rake::Task['after_party:remove_migration_status_on_filters'] } + + let(:procedure) { create(:simple_procedure) } + let(:instructeur_1) { create(:instructeur) } + let(:instructeur_2) { create(:instructeur) } + + let(:assign_to_1) { create(:assign_to, procedure: procedure, instructeur: instructeur_1) } + let(:assign_to_2) { create(:assign_to, procedure: procedure, instructeur: instructeur_2) } + + let(:procedure_presentation_with_migration) { create(:procedure_presentation, assign_to: assign_to_1, filters: filters.merge('migrated': true)) } + let(:procedure_presentation_without_migration) { create(:procedure_presentation, assign_to: assign_to_2, filters: filters) } + + let(:filters) do + { "suivis" => [{ "table" => "user", "column" => "email", "value" => "test@example.com" }] } + end + + subject(:run_task) do + procedure_presentation_with_migration + procedure_presentation_without_migration + + rake_task.invoke + + procedure_presentation_with_migration.reload + procedure_presentation_without_migration.reload + end + + after { rake_task.reenable } + + context 'when the procedure presentation has a "migrated" key' do + it 'removes the "migrated" key' do + run_task + expect(procedure_presentation_with_migration.filters).not_to have_key('migrated') + end + + it 'leaves other keys unchanged' do + run_task + expect(procedure_presentation_with_migration.filters['suivis']).to be_present + end + end + + context 'when the procedure presentation doesn’t have a "migrated" key' do + it 'leaves keys unchanged' do + run_task + expect(procedure_presentation_without_migration.filters['suivis']).to be_present + end + end + + context 'when the procedure presentation is invalid' do + before do + procedure_presentation_with_migration.update_column( + :sort, + { table: 'invalid-table', column: 'invalid-column', order: 'invalid-order' } + ) + end + + it 'removes the "migrated" key properly' do + run_task + expect(procedure_presentation_with_migration).not_to be_valid + expect(procedure_presentation_with_migration.filters).not_to have_key('migrated') + end + + it 'leaves the other keys unchanged' do + run_task + expect(procedure_presentation_without_migration.filters['suivis']).to be_present + end + end +end diff --git a/spec/mailers/dossier_mailer_spec.rb b/spec/mailers/dossier_mailer_spec.rb index db4598fa7..e68a073ee 100644 --- a/spec/mailers/dossier_mailer_spec.rb +++ b/spec/mailers/dossier_mailer_spec.rb @@ -151,7 +151,7 @@ RSpec.describe DossierMailer, type: :mailer do it { expect(subject.body).to include("n° #{dossier.id} ") } it { expect(subject.body).to include(dossier.procedure.libelle) } it { expect(subject.body).to include("PDF") } - it { expect(subject.body).to include("Vous avez un mois pour commencer l’instruction du dossier.") } + it { expect(subject.body).to include("Vous avez deux semaines pour commencer l’instruction du dossier.") } end describe 'termine' do @@ -163,7 +163,7 @@ RSpec.describe DossierMailer, type: :mailer do it { expect(subject.body).to include("n° #{dossier.id} ") } it { expect(subject.body).to include(dossier.procedure.libelle) } it { expect(subject.body).to include("PDF") } - it { expect(subject.body).to include("Vous avez un mois pour archiver le dossier.") } + it { expect(subject.body).to include("Vous avez deux semaines pour archiver le dossier.") } end end @@ -178,7 +178,7 @@ RSpec.describe DossierMailer, type: :mailer do it { expect(subject.body).to include("n° #{dossier.id} ") } it { expect(subject.body).to include(dossier.procedure.libelle) } it { expect(subject.body).to include("PDF") } - it { expect(subject.body).to include("Vous pouvez retrouver votre dossier pendant encore un mois. Vous n’avez rien à faire.") } + it { expect(subject.body).to include("Vous pouvez retrouver votre dossier pendant encore deux semaines. Vous n’avez rien à faire.") } it { expect(subject.body).to include("Si vous souhaitez conserver votre dossier plus longtemps, vous pouvez prolonger sa durée de conservation dans l’interface.") } end @@ -192,7 +192,7 @@ RSpec.describe DossierMailer, type: :mailer do it { expect(subject.body).to include("n° #{dossier.id} ") } it { expect(subject.body).to include(dossier.procedure.libelle) } it { expect(subject.body).to include("PDF") } - it { expect(subject.body).to include("Vous pouvez retrouver votre dossier pendant encore un mois. Vous n’avez rien à faire.") } + it { expect(subject.body).to include("Vous pouvez retrouver votre dossier pendant encore deux semaines. Vous n’avez rien à faire.") } end end diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 1a3521090..213cef8b0 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -40,7 +40,7 @@ describe Dossier do describe 'brouillon_close_to_expiration' do let(:procedure) { create(:procedure, :published, duree_conservation_dossiers_dans_ds: 6) } let!(:young_dossier) { create(:dossier, :en_construction, procedure: procedure) } - let!(:expiring_dossier) { create(:dossier, created_at: 170.days.ago, procedure: procedure) } + let!(:expiring_dossier) { create(:dossier, created_at: 175.days.ago, procedure: procedure) } let!(:just_expired_dossier) { create(:dossier, created_at: (6.months + 1.hour + 10.seconds).ago, procedure: procedure) } let!(:long_expired_dossier) { create(:dossier, created_at: 1.year.ago, procedure: procedure) } @@ -66,7 +66,7 @@ describe Dossier do describe 'en_construction_close_to_expiration' do let(:procedure) { create(:procedure, :published, duree_conservation_dossiers_dans_ds: 6) } let!(:young_dossier) { create(:dossier, procedure: procedure) } - let!(:expiring_dossier) { create(:dossier, :en_construction, en_construction_at: 170.days.ago, procedure: procedure) } + let!(:expiring_dossier) { create(:dossier, :en_construction, en_construction_at: 175.days.ago, procedure: procedure) } let!(:just_expired_dossier) { create(:dossier, :en_construction, en_construction_at: (6.months + 1.hour + 10.seconds).ago, procedure: procedure) } let!(:long_expired_dossier) { create(:dossier, :en_construction, en_construction_at: 1.year.ago, procedure: procedure) } @@ -92,7 +92,7 @@ describe Dossier do describe 'en_instruction_close_to_expiration' do let(:procedure) { create(:procedure, :published, duree_conservation_dossiers_dans_ds: 6) } let!(:young_dossier) { create(:dossier, procedure: procedure) } - let!(:expiring_dossier) { create(:dossier, :en_instruction, en_instruction_at: 170.days.ago, procedure: procedure) } + let!(:expiring_dossier) { create(:dossier, :en_instruction, en_instruction_at: 175.days.ago, procedure: procedure) } let!(:just_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: (6.months + 1.hour + 10.seconds).ago, procedure: procedure) } let!(:long_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: 1.year.ago, procedure: procedure) } diff --git a/spec/services/expired_dossiers_deletion_service_spec.rb b/spec/services/expired_dossiers_deletion_service_spec.rb index 97de70859..69a5944f1 100644 --- a/spec/services/expired_dossiers_deletion_service_spec.rb +++ b/spec/services/expired_dossiers_deletion_service_spec.rb @@ -8,7 +8,7 @@ describe ExpiredDossiersDeletionService do describe '#process_expired_dossiers_brouillon' do let(:today) { Time.zone.now.at_midnight } - let(:date_close_to_expiration) { Date.today - procedure.duree_conservation_dossiers_dans_ds.months + 1.month } + let(:date_close_to_expiration) { Date.today - procedure.duree_conservation_dossiers_dans_ds.months + 2.weeks } let(:date_expired) { Date.today - procedure.duree_conservation_dossiers_dans_ds.months - 6.days } let(:date_not_expired) { Date.today - procedure.duree_conservation_dossiers_dans_ds.months + 2.months } @@ -56,15 +56,15 @@ describe ExpiredDossiersDeletionService do before { ExpiredDossiersDeletionService.send_brouillon_expiration_notices } - context 'when the dossier is not closed to expiration' do - let(:created_at) { (conservation_par_defaut - 1.month - 1.day).ago } + context 'when the dossier is not close to expiration' do + let(:created_at) { (conservation_par_defaut - 2.weeks - 1.day).ago } it { expect(dossier.reload.brouillon_close_to_expiration_notice_sent_at).to be_nil } it { expect(DossierMailer).not_to have_received(:notify_brouillon_near_deletion) } end - context 'when the dossier is closed to expiration' do - let(:created_at) { (conservation_par_defaut - 1.month + 1.day).ago } + context 'when the dossier is close to expiration' do + let(:created_at) { (conservation_par_defaut - 2.weeks + 1.day).ago } it { expect(dossier.reload.brouillon_close_to_expiration_notice_sent_at).not_to be_nil } it { expect(DossierMailer).to have_received(:notify_brouillon_near_deletion).once } @@ -73,8 +73,8 @@ describe ExpiredDossiersDeletionService do end context 'with 2 dossiers to notice' do - let!(:dossier_1) { create(:dossier, procedure: procedure, user: user, created_at: (conservation_par_defaut - 1.month + 1.day).ago) } - let!(:dossier_2) { create(:dossier, procedure: procedure_2, user: user, created_at: (conservation_par_defaut - 1.month + 1.day).ago) } + let!(:dossier_1) { create(:dossier, procedure: procedure, user: user, created_at: (conservation_par_defaut - 2.weeks + 1.day).ago) } + let!(:dossier_2) { create(:dossier, procedure: procedure_2, user: user, created_at: (conservation_par_defaut - 2.weeks + 1.day).ago) } before { ExpiredDossiersDeletionService.send_brouillon_expiration_notices } @@ -146,7 +146,7 @@ describe ExpiredDossiersDeletionService do before { ExpiredDossiersDeletionService.send_en_construction_expiration_notices } context 'when the dossier is not near deletion' do - let(:en_construction_at) { (conservation_par_defaut - 1.month - 1.day).ago } + let(:en_construction_at) { (conservation_par_defaut - 2.weeks - 1.day).ago } it { expect(dossier.reload.en_construction_close_to_expiration_notice_sent_at).to be_nil } it { expect(DossierMailer).not_to have_received(:notify_near_deletion_to_user) } @@ -154,7 +154,7 @@ describe ExpiredDossiersDeletionService do end context 'when the dossier is near deletion' do - let(:en_construction_at) { (conservation_par_defaut - 1.month + 1.day).ago } + let(:en_construction_at) { (conservation_par_defaut - 2.weeks + 1.day).ago } it { expect(dossier.reload.en_construction_close_to_expiration_notice_sent_at).not_to be_nil } @@ -167,8 +167,8 @@ describe ExpiredDossiersDeletionService do end context 'with 2 dossiers to notice' do - let!(:dossier_1) { create(:dossier, :en_construction, procedure: procedure, user: user, en_construction_at: (conservation_par_defaut - 1.month + 1.day).ago) } - let!(:dossier_2) { create(:dossier, :en_construction, procedure: procedure_2, user: user, en_construction_at: (conservation_par_defaut - 1.month + 1.day).ago) } + let!(:dossier_1) { create(:dossier, :en_construction, procedure: procedure, user: user, en_construction_at: (conservation_par_defaut - 2.weeks + 1.day).ago) } + let!(:dossier_2) { create(:dossier, :en_construction, procedure: procedure_2, user: user, en_construction_at: (conservation_par_defaut - 2.weeks + 1.day).ago) } let!(:instructeur) { create(:instructeur) } @@ -187,7 +187,7 @@ describe ExpiredDossiersDeletionService do context 'when an instructeur is also administrateur' do let!(:administrateur) { procedure.administrateurs.first } - let!(:dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: (conservation_par_defaut - 1.month + 1.day).ago) } + let!(:dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: (conservation_par_defaut - 2.weeks + 1.day).ago) } before do administrateur.instructeur.followed_dossiers << dossier @@ -290,7 +290,7 @@ describe ExpiredDossiersDeletionService do before { ExpiredDossiersDeletionService.send_termine_expiration_notices } context 'when the dossier is not near deletion' do - let(:processed_at) { (conservation_par_defaut - 1.month - 1.day).ago } + let(:processed_at) { (conservation_par_defaut - 2.weeks - 1.day).ago } it { expect(dossier.reload.termine_close_to_expiration_notice_sent_at).to be_nil } it { expect(DossierMailer).not_to have_received(:notify_near_deletion_to_user) } @@ -298,7 +298,7 @@ describe ExpiredDossiersDeletionService do end context 'when the dossier is near deletion' do - let(:processed_at) { (conservation_par_defaut - 1.month + 1.day).ago } + let(:processed_at) { (conservation_par_defaut - 2.weeks + 1.day).ago } it { expect(dossier.reload.termine_close_to_expiration_notice_sent_at).not_to be_nil } @@ -311,8 +311,8 @@ describe ExpiredDossiersDeletionService do end context 'with 2 dossiers to notice' do - let!(:dossier_1) { create(:dossier, :accepte, procedure: procedure, user: user, processed_at: (conservation_par_defaut - 1.month + 1.day).ago) } - let!(:dossier_2) { create(:dossier, :accepte, procedure: procedure_2, user: user, processed_at: (conservation_par_defaut - 1.month + 1.day).ago) } + let!(:dossier_1) { create(:dossier, :accepte, procedure: procedure, user: user, processed_at: (conservation_par_defaut - 2.weeks + 1.day).ago) } + let!(:dossier_2) { create(:dossier, :accepte, procedure: procedure_2, user: user, processed_at: (conservation_par_defaut - 2.weeks + 1.day).ago) } let!(:instructeur) { create(:instructeur) } @@ -331,7 +331,7 @@ describe ExpiredDossiersDeletionService do context 'when an instructeur is also administrateur' do let!(:administrateur) { procedure.administrateurs.first } - let!(:dossier) { create(:dossier, :accepte, procedure: procedure, processed_at: (conservation_par_defaut - 1.month + 1.day).ago) } + let!(:dossier) { create(:dossier, :accepte, procedure: procedure, processed_at: (conservation_par_defaut - 2.weeks + 1.day).ago) } before do administrateur.instructeur.followed_dossiers << dossier