commit
8fb6e32132
33 changed files with 3641 additions and 1639 deletions
|
@ -2,14 +2,24 @@ class Champs::PieceJustificativeController < ApplicationController
|
||||||
before_action :authenticate_logged_user!
|
before_action :authenticate_logged_user!
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@champ = policy_scope(Champ).find(params[:champ_id])
|
if attach_piece_justificative_or_retry
|
||||||
|
|
||||||
@champ.piece_justificative_file.attach(params[:blob_signed_id])
|
|
||||||
if @champ.save
|
|
||||||
render :show
|
render :show
|
||||||
else
|
else
|
||||||
errors = @champ.errors.full_messages
|
render json: { errors: @champ.errors.full_messages }, status: 422
|
||||||
render :json => { errors: errors }, :status => 422
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def attach_piece_justificative
|
||||||
|
@champ = policy_scope(Champ).find(params[:champ_id])
|
||||||
|
@champ.piece_justificative_file.attach(params[:blob_signed_id])
|
||||||
|
@champ.save
|
||||||
|
end
|
||||||
|
|
||||||
|
def attach_piece_justificative_or_retry
|
||||||
|
attach_piece_justificative
|
||||||
|
rescue ActiveRecord::StaleObjectError
|
||||||
|
attach_piece_justificative
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
21
app/controllers/instructeurs/commentaires_controller.rb
Normal file
21
app/controllers/instructeurs/commentaires_controller.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Instructeurs
|
||||||
|
class CommentairesController < ProceduresController
|
||||||
|
def destroy
|
||||||
|
commentaire = Dossier.find(params[:dossier_id]).commentaires.find(params[:id])
|
||||||
|
if commentaire.sent_by?(current_instructeur)
|
||||||
|
commentaire.piece_jointe.purge_later if commentaire.piece_jointe.attached?
|
||||||
|
commentaire.discard!
|
||||||
|
commentaire.update!(body: '')
|
||||||
|
flash[:notice] = t('views.shared.commentaires.destroy.notice')
|
||||||
|
else
|
||||||
|
flash[:alert] = I18n.t('views.shared.commentaires.destroy.alert_reasons.acl')
|
||||||
|
end
|
||||||
|
redirect_to(messagerie_instructeur_dossier_path(params[:procedure_id], params[:dossier_id]))
|
||||||
|
rescue Discard::RecordNotDiscarded
|
||||||
|
flash[:alert] = I18n.t('views.shared.commentaires.destroy.alert_reasons.already_discarded')
|
||||||
|
redirect_to(messagerie_instructeur_dossier_path(params[:procedure_id], params[:dossier_id]))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -190,10 +190,10 @@ module NewAdministrateur
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_routing_enabled
|
def update_routing_enabled
|
||||||
procedure.update!(routing_enabled: true)
|
procedure.update!(routing_enabled_params)
|
||||||
|
|
||||||
redirect_to admin_procedure_groupe_instructeurs_path(procedure),
|
redirect_to admin_procedure_groupe_instructeurs_path(procedure),
|
||||||
notice: "Le routage est activé."
|
notice: "Le routage est #{procedure.routing_enabled? ? "activée" : "désactivée"}."
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_instructeurs_self_management_enabled
|
def update_instructeurs_self_management_enabled
|
||||||
|
@ -326,5 +326,9 @@ module NewAdministrateur
|
||||||
def instructeurs_self_management_enabled_params
|
def instructeurs_self_management_enabled_params
|
||||||
params.require(:procedure).permit(:instructeurs_self_management_enabled)
|
params.require(:procedure).permit(:instructeurs_self_management_enabled)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def routing_enabled_params
|
||||||
|
{ routing_enabled: params.require(:routing) == 'enable' }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -251,11 +251,11 @@ module NewAdministrateur
|
||||||
end
|
end
|
||||||
|
|
||||||
def procedure_params
|
def procedure_params
|
||||||
editable_params = [:libelle, :description, :organisation, :direction, :lien_site_web, :cadre_juridique, :deliberation, :notice, :web_hook_url, :declarative_with_state, :euro_flag, :logo, :auto_archive_on, :monavis_embed, :api_entreprise_token]
|
editable_params = [:libelle, :description, :organisation, :direction, :lien_site_web, :cadre_juridique, :deliberation, :notice, :web_hook_url, :declarative_with_state, :logo, :auto_archive_on, :monavis_embed, :api_entreprise_token, :duree_conservation_dossiers_dans_ds]
|
||||||
permited_params = if @procedure&.locked?
|
permited_params = if @procedure&.locked?
|
||||||
params.require(:procedure).permit(*editable_params)
|
params.require(:procedure).permit(*editable_params)
|
||||||
else
|
else
|
||||||
params.require(:procedure).permit(*editable_params, :duree_conservation_dossiers_dans_ds, :duree_conservation_dossiers_hors_ds, :for_individual, :path)
|
params.require(:procedure).permit(*editable_params, :for_individual, :path)
|
||||||
end
|
end
|
||||||
if permited_params[:auto_archive_on].present?
|
if permited_params[:auto_archive_on].present?
|
||||||
permited_params[:auto_archive_on] = Date.parse(permited_params[:auto_archive_on]) + 1.day
|
permited_params[:auto_archive_on] = Date.parse(permited_params[:auto_archive_on]) + 1.day
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
module Users
|
module Users
|
||||||
class ProfilController < UserController
|
class ProfilController < UserController
|
||||||
before_action :ensure_update_email_is_authorized, only: :update_email
|
before_action :ensure_update_email_is_authorized, only: :update_email
|
||||||
|
before_action :find_transfers, only: [:show, :renew_api_token]
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@waiting_merge_emails = waiting_merge_emails
|
|
||||||
@waiting_transfers = current_user.dossiers.joins(:transfer).group('dossier_transfers.email').count.to_a
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def renew_api_token
|
def renew_api_token
|
||||||
|
@ -56,6 +55,11 @@ module Users
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def find_transfers
|
||||||
|
@waiting_merge_emails = waiting_merge_emails
|
||||||
|
@waiting_transfers = current_user.dossiers.joins(:transfer).group('dossier_transfers.email').count.to_a
|
||||||
|
end
|
||||||
|
|
||||||
def waiting_merge_emails
|
def waiting_merge_emails
|
||||||
users_requesting_merge.pluck(:email)
|
users_requesting_merge.pluck(:email)
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,6 +24,7 @@ module CommentaireHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def pretty_commentaire(commentaire)
|
def pretty_commentaire(commentaire)
|
||||||
|
return t('views.shared.commentaires.destroy.deleted_body') if commentaire.discarded?
|
||||||
body_formatted = commentaire.sent_by_system? ? commentaire.body : simple_format(commentaire.body)
|
body_formatted = commentaire.sent_by_system? ? commentaire.body : simple_format(commentaire.body)
|
||||||
sanitize(body_formatted)
|
sanitize(body_formatted)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module ConservationDeDonneesHelper
|
module ConservationDeDonneesHelper
|
||||||
def politiques_conservation_de_donnees(procedure)
|
def politiques_conservation_de_donnees(procedure)
|
||||||
[conservation_dans_ds(procedure), conservation_hors_ds(procedure)].compact
|
[conservation_dans_ds(procedure)].compact
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -10,10 +10,4 @@ module ConservationDeDonneesHelper
|
||||||
"Dans #{APPLICATION_NAME} : #{procedure.duree_conservation_dossiers_dans_ds} mois"
|
"Dans #{APPLICATION_NAME} : #{procedure.duree_conservation_dossiers_dans_ds} mois"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def conservation_hors_ds(procedure)
|
|
||||||
if procedure.duree_conservation_dossiers_hors_ds.present?
|
|
||||||
"Par l’administration : #{procedure.duree_conservation_dossiers_hors_ds} mois"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,7 @@ class DossierMailer < ApplicationMailer
|
||||||
|
|
||||||
layout 'mailers/layout'
|
layout 'mailers/layout'
|
||||||
default from: NO_REPLY_EMAIL
|
default from: NO_REPLY_EMAIL
|
||||||
|
after_action :prevent_perform_deliveries, only: [:notify_new_answer]
|
||||||
|
|
||||||
def notify_new_draft(dossier)
|
def notify_new_draft(dossier)
|
||||||
I18n.with_locale(dossier.user_locale) do
|
I18n.with_locale(dossier.user_locale) do
|
||||||
|
@ -20,12 +21,14 @@ class DossierMailer < ApplicationMailer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify_new_answer(dossier, body = nil)
|
def notify_new_answer
|
||||||
|
commentaire = params[:commentaire]
|
||||||
|
dossier = commentaire.dossier
|
||||||
I18n.with_locale(dossier.user_locale) do
|
I18n.with_locale(dossier.user_locale) do
|
||||||
@dossier = dossier
|
@dossier = dossier
|
||||||
@service = dossier.procedure.service
|
@service = dossier.procedure.service
|
||||||
@logo_url = attach_logo(dossier.procedure)
|
@logo_url = attach_logo(dossier.procedure)
|
||||||
@body = body
|
@body = commentaire.body
|
||||||
@subject = default_i18n_subject(dossier_id: dossier.id, libelle_demarche: dossier.procedure.libelle)
|
@subject = default_i18n_subject(dossier_id: dossier.id, libelle_demarche: dossier.procedure.libelle)
|
||||||
|
|
||||||
mail(to: dossier.user_email_for(:notification), subject: @subject) do |format|
|
mail(to: dossier.user_email_for(:notification), subject: @subject) do |format|
|
||||||
|
@ -168,6 +171,10 @@ class DossierMailer < ApplicationMailer
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
def prevent_perform_deliveries
|
||||||
|
mail.perform_deliveries = false if params[:commentaire].discarded?
|
||||||
|
end
|
||||||
|
|
||||||
# This is an override of `default_i18n_subject` method
|
# This is an override of `default_i18n_subject` method
|
||||||
# https://api.rubyonrails.org/v5.0.0/classes/ActionMailer/Base.html#method-i-default_i18n_subject
|
# https://api.rubyonrails.org/v5.0.0/classes/ActionMailer/Base.html#method-i-default_i18n_subject
|
||||||
#
|
#
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# body :string
|
# body :string
|
||||||
|
# discarded_at :datetime
|
||||||
# email :string
|
# email :string
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
|
@ -13,6 +14,7 @@
|
||||||
#
|
#
|
||||||
class Commentaire < ApplicationRecord
|
class Commentaire < ApplicationRecord
|
||||||
include FileValidationConcern
|
include FileValidationConcern
|
||||||
|
include Discard::Model
|
||||||
|
|
||||||
self.ignored_columns = [:user_id]
|
self.ignored_columns = [:user_id]
|
||||||
belongs_to :dossier, inverse_of: :commentaires, touch: true, optional: false
|
belongs_to :dossier, inverse_of: :commentaires, touch: true, optional: false
|
||||||
|
@ -24,7 +26,7 @@ class Commentaire < ApplicationRecord
|
||||||
|
|
||||||
has_one_attached :piece_jointe
|
has_one_attached :piece_jointe
|
||||||
|
|
||||||
validates :body, presence: { message: "ne peut être vide" }
|
validates :body, presence: { message: "ne peut être vide" }, unless: :discarded?
|
||||||
|
|
||||||
FILE_MAX_SIZE = 20.megabytes
|
FILE_MAX_SIZE = 20.megabytes
|
||||||
validates :piece_jointe,
|
validates :piece_jointe,
|
||||||
|
@ -75,7 +77,11 @@ class Commentaire < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def sent_by?(someone)
|
def sent_by?(someone)
|
||||||
email == someone.email
|
someone.present? && email == someone&.email
|
||||||
|
end
|
||||||
|
|
||||||
|
def soft_deletable?(connected_user)
|
||||||
|
sent_by?(connected_user) && sent_by_instructeur? && !discarded?
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_url
|
def file_url
|
||||||
|
@ -92,13 +98,15 @@ class Commentaire < ApplicationRecord
|
||||||
# - If a user or an invited user posted a commentaire, do nothing,
|
# - If a user or an invited user posted a commentaire, do nothing,
|
||||||
# the notification system will properly
|
# the notification system will properly
|
||||||
# - Otherwise, a instructeur posted a commentaire, we need to notify the user
|
# - Otherwise, a instructeur posted a commentaire, we need to notify the user
|
||||||
if sent_by_instructeur? || sent_by_expert?
|
if sent_by_instructeur?
|
||||||
|
notify_user(wait: 5.minutes)
|
||||||
|
elsif sent_by_expert?
|
||||||
notify_user
|
notify_user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify_user
|
def notify_user(job_options = {})
|
||||||
DossierMailer.notify_new_answer(dossier, body).deliver_later
|
DossierMailer.with(commentaire: self).notify_new_answer.deliver_later(job_options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def messagerie_available?
|
def messagerie_available?
|
||||||
|
|
|
@ -83,14 +83,16 @@ class Dossier < ApplicationRecord
|
||||||
has_many :avis, inverse_of: :dossier, dependent: :destroy
|
has_many :avis, inverse_of: :dossier, dependent: :destroy
|
||||||
has_many :experts, through: :avis
|
has_many :experts, through: :avis
|
||||||
has_many :traitements, -> { order(:processed_at) }, inverse_of: :dossier, dependent: :destroy do
|
has_many :traitements, -> { order(:processed_at) }, inverse_of: :dossier, dependent: :destroy do
|
||||||
def passer_en_construction(processed_at: Time.zone.now)
|
def passer_en_construction(instructeur: nil, processed_at: Time.zone.now)
|
||||||
build(state: Dossier.states.fetch(:en_construction),
|
build(state: Dossier.states.fetch(:en_construction),
|
||||||
|
instructeur_email: instructeur&.email,
|
||||||
process_expired: false,
|
process_expired: false,
|
||||||
processed_at: processed_at)
|
processed_at: processed_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def passer_en_instruction(processed_at: Time.zone.now)
|
def passer_en_instruction(instructeur: nil, processed_at: Time.zone.now)
|
||||||
build(state: Dossier.states.fetch(:en_instruction),
|
build(state: Dossier.states.fetch(:en_instruction),
|
||||||
|
instructeur_email: instructeur&.email,
|
||||||
process_expired: false,
|
process_expired: false,
|
||||||
processed_at: processed_at)
|
processed_at: processed_at)
|
||||||
end
|
end
|
||||||
|
@ -735,7 +737,7 @@ class Dossier < ApplicationRecord
|
||||||
self.en_construction_close_to_expiration_notice_sent_at = nil
|
self.en_construction_close_to_expiration_notice_sent_at = nil
|
||||||
self.conservation_extension = 0.days
|
self.conservation_extension = 0.days
|
||||||
self.en_instruction_at = self.traitements
|
self.en_instruction_at = self.traitements
|
||||||
.passer_en_instruction
|
.passer_en_instruction(instructeur: instructeur)
|
||||||
.processed_at
|
.processed_at
|
||||||
save!
|
save!
|
||||||
|
|
||||||
|
@ -759,7 +761,7 @@ class Dossier < ApplicationRecord
|
||||||
self.en_construction_close_to_expiration_notice_sent_at = nil
|
self.en_construction_close_to_expiration_notice_sent_at = nil
|
||||||
self.conservation_extension = 0.days
|
self.conservation_extension = 0.days
|
||||||
self.en_construction_at = self.traitements
|
self.en_construction_at = self.traitements
|
||||||
.passer_en_construction
|
.passer_en_construction(instructeur: instructeur)
|
||||||
.processed_at
|
.processed_at
|
||||||
save!
|
save!
|
||||||
log_dossier_operation(instructeur, :repasser_en_construction)
|
log_dossier_operation(instructeur, :repasser_en_construction)
|
||||||
|
@ -770,7 +772,7 @@ class Dossier < ApplicationRecord
|
||||||
self.termine_close_to_expiration_notice_sent_at = nil
|
self.termine_close_to_expiration_notice_sent_at = nil
|
||||||
self.conservation_extension = 0.days
|
self.conservation_extension = 0.days
|
||||||
self.en_instruction_at = self.traitements
|
self.en_instruction_at = self.traitements
|
||||||
.passer_en_instruction
|
.passer_en_instruction(instructeur: instructeur)
|
||||||
.processed_at
|
.processed_at
|
||||||
attestation&.destroy
|
attestation&.destroy
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
class Procedure < ApplicationRecord
|
class Procedure < ApplicationRecord
|
||||||
|
self.ignored_columns = [:duree_conservation_dossiers_hors_ds]
|
||||||
include ProcedureStatsConcern
|
include ProcedureStatsConcern
|
||||||
include EncryptableConcern
|
include EncryptableConcern
|
||||||
include FileValidationConcern
|
include FileValidationConcern
|
||||||
|
@ -238,7 +239,6 @@ class Procedure < ApplicationRecord
|
||||||
validate :check_juridique
|
validate :check_juridique
|
||||||
validates :path, presence: true, format: { with: /\A[a-z0-9_\-]{3,200}\z/ }, uniqueness: { scope: [:path, :closed_at, :hidden_at, :unpublished_at], case_sensitive: false }
|
validates :path, presence: true, format: { with: /\A[a-z0-9_\-]{3,200}\z/ }, uniqueness: { scope: [:path, :closed_at, :hidden_at, :unpublished_at], case_sensitive: false }
|
||||||
validates :duree_conservation_dossiers_dans_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: MAX_DUREE_CONSERVATION }
|
validates :duree_conservation_dossiers_dans_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: MAX_DUREE_CONSERVATION }
|
||||||
validates :duree_conservation_dossiers_hors_ds, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
|
||||||
validates_with MonAvisEmbedValidator
|
validates_with MonAvisEmbedValidator
|
||||||
|
|
||||||
FILE_MAX_SIZE = 20.megabytes
|
FILE_MAX_SIZE = 20.megabytes
|
||||||
|
|
|
@ -201,7 +201,7 @@ class User < ApplicationRecord
|
||||||
|
|
||||||
def merge(old_user)
|
def merge(old_user)
|
||||||
transaction do
|
transaction do
|
||||||
old_user.dossiers.update_all(user_id: id)
|
old_user.dossiers.with_discarded.update_all(user_id: id)
|
||||||
old_user.invites.update_all(user_id: id)
|
old_user.invites.update_all(user_id: id)
|
||||||
old_user.merge_logs.update_all(user_id: id)
|
old_user.merge_logs.update_all(user_id: id)
|
||||||
|
|
||||||
|
|
|
@ -2,18 +2,12 @@
|
||||||
- if traitements.any?
|
- if traitements.any?
|
||||||
%ul.tab-list
|
%ul.tab-list
|
||||||
- traitements.each do |traitement|
|
- traitements.each do |traitement|
|
||||||
|
%li
|
||||||
|
- processed_at = l(traitement.processed_at, format: '%d %B %Y à %R')
|
||||||
- if traitement.instructeur_email.present?
|
- if traitement.instructeur_email.present?
|
||||||
%li
|
= t(".with_email.#{traitement.state}", processed_at: processed_at, email: traitement.instructeur_email)
|
||||||
= "Le #{l(traitement.processed_at, format: '%d %B %Y à %R')}, "
|
|
||||||
= traitement.instructeur_email
|
|
||||||
a
|
|
||||||
%strong= t(traitement.state, scope: 'activerecord.attributes.traitement.state').downcase
|
|
||||||
ce dossier
|
|
||||||
- else
|
- else
|
||||||
%li
|
= t(".without_email.#{traitement.state}", processed_at: processed_at)
|
||||||
= "Le #{l(traitement.processed_at, format: '%d %B %Y à %R')}, "
|
|
||||||
ce dossier a été
|
|
||||||
%strong= t(traitement.state, scope: 'activerecord.attributes.traitement.state').downcase
|
|
||||||
- else
|
- else
|
||||||
%p.tab-paragraph Aucune décision n’a été rendue
|
%p.tab-paragraph Aucune décision n’a été rendue
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
.card
|
.card
|
||||||
.card-title Routage
|
.card-title Routage
|
||||||
|
- if !procedure.routee?
|
||||||
%p.notice= t('.notice_html')
|
%p.notice= t('.notice_html')
|
||||||
|
|
||||||
= link_to t('.button.routing_enable'), update_routing_enabled_admin_procedure_groupe_instructeurs_path(procedure), class: 'button primary mt-1', method: 'patch'
|
- if procedure.routee?
|
||||||
|
- if procedure.routing_enabled? && procedure.groupe_instructeurs.size == 1
|
||||||
|
= link_to t('.button.routing_disable'), update_routing_enabled_admin_procedure_groupe_instructeurs_path(procedure, routing: :disable), class: 'button primary mt-1', method: 'patch'
|
||||||
|
- else
|
||||||
|
= link_to t('.button.routing_enable'), update_routing_enabled_admin_procedure_groupe_instructeurs_path(procedure, routing: :enable), class: 'button primary mt-1', method: 'patch'
|
||||||
|
|
||||||
.card-title.mt-4 L‘autogestion des instructeurs
|
.card-title.mt-4 L‘autogestion des instructeurs
|
||||||
%p.notice= t('.self_managment_notice_html')
|
%p.notice= t('.self_managment_notice_html')
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
'Instructeurs'] }
|
'Instructeurs'] }
|
||||||
|
|
||||||
.container.groupe-instructeur
|
.container.groupe-instructeur
|
||||||
|
= render partial: 'new_administrateur/groupe_instructeurs/routing', locals: { procedure: @procedure }
|
||||||
|
|
||||||
- if @procedure.routee?
|
- if @procedure.routee?
|
||||||
= render partial: 'new_administrateur/groupe_instructeurs/edit', locals: { procedure: @procedure, groupes_instructeurs: @groupes_instructeurs }
|
= render partial: 'new_administrateur/groupe_instructeurs/edit', locals: { procedure: @procedure, groupes_instructeurs: @groupes_instructeurs }
|
||||||
- else
|
- else
|
||||||
= render partial: 'new_administrateur/groupe_instructeurs/routing', locals: { procedure: @procedure }
|
|
||||||
= render partial: 'new_administrateur/groupe_instructeurs/instructeurs',
|
= render partial: 'new_administrateur/groupe_instructeurs/instructeurs',
|
||||||
locals: { procedure: @procedure,
|
locals: { procedure: @procedure,
|
||||||
groupe_instructeur: @procedure.defaut_groupe_instructeur,
|
groupe_instructeur: @procedure.defaut_groupe_instructeur,
|
||||||
|
|
|
@ -11,6 +11,11 @@
|
||||||
.rich-text= pretty_commentaire(commentaire)
|
.rich-text= pretty_commentaire(commentaire)
|
||||||
|
|
||||||
.message-extras.flex.justify-start
|
.message-extras.flex.justify-start
|
||||||
|
- if commentaire.soft_deletable?(connected_user)
|
||||||
|
= button_to instructeur_commentaire_path(commentaire.dossier.procedure, commentaire.dossier, commentaire), method: :delete, class: 'button danger', data: { confirm: t('views.shared.commentaires.destroy.confirm') } do
|
||||||
|
%span.icon.delete
|
||||||
|
= t('views.shared.commentaires.destroy.button')
|
||||||
|
|
||||||
- if commentaire.piece_jointe.attached?
|
- if commentaire.piece_jointe.attached?
|
||||||
.attachment-link
|
.attachment-link
|
||||||
= render partial: "shared/attachment/show", locals: { attachment: commentaire.piece_jointe.attachment }
|
= render partial: "shared/attachment/show", locals: { attachment: commentaire.piece_jointe.attachment }
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#profil-page.container
|
#profil-page.container
|
||||||
%h1 Profil
|
%h1 Profil
|
||||||
|
|
||||||
- if @waiting_merge_emails.any?
|
- if @waiting_merge_emails.present?
|
||||||
.card
|
.card
|
||||||
.card-title Demande de fusion de comptes
|
.card-title Demande de fusion de comptes
|
||||||
%p
|
%p
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
application_name: APPLICATION_NAME,
|
application_name: APPLICATION_NAME,
|
||||||
legit_admin_domains: LEGIT_ADMIN_DOMAINS.join(', '))
|
legit_admin_domains: LEGIT_ADMIN_DOMAINS.join(', '))
|
||||||
|
|
||||||
= form_for @current_user, url: update_email_path, method: :patch, html: { class: 'form' } do |f|
|
= form_for current_user, url: update_email_path, method: :patch, html: { class: 'form' } do |f|
|
||||||
= f.email_field :email, value: nil, placeholder: 'Nouvelle adresse email', required: true
|
= f.email_field :email, value: nil, placeholder: 'Nouvelle adresse email', required: true
|
||||||
= f.submit "Changer mon adresse", class: 'button primary'
|
= f.submit "Changer mon adresse", class: 'button primary'
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
= email_field_tag :next_owner, nil, required: true
|
= email_field_tag :next_owner, nil, required: true
|
||||||
= submit_tag "Transférer tous mes dossiers", class: 'button primary', data: { confirm: t('.transfer_confirmation') }
|
= submit_tag "Transférer tous mes dossiers", class: 'button primary', data: { confirm: t('.transfer_confirmation') }
|
||||||
|
|
||||||
- if @waiting_transfers.any?
|
- if @waiting_transfers.present?
|
||||||
.card.warning
|
.card.warning
|
||||||
.card-title= t('.waiting_transfers')
|
.card-title= t('.waiting_transfers')
|
||||||
%ul
|
%ul
|
||||||
|
|
|
@ -17,3 +17,17 @@ fr:
|
||||||
download_archive: Télécharger une archive au format .zip de tous les dossiers et leurs pièces jointes
|
download_archive: Télécharger une archive au format .zip de tous les dossiers et leurs pièces jointes
|
||||||
archive_pending_html: Archive en cours de création<br>(demandée il y a %{created_period})
|
archive_pending_html: Archive en cours de création<br>(demandée il y a %{created_period})
|
||||||
archive_ready_html: Télécharger l’archive<br>(demandée il y a %{generated_period})
|
archive_ready_html: Télécharger l’archive<br>(demandée il y a %{generated_period})
|
||||||
|
dossiers:
|
||||||
|
decisions_rendues_block:
|
||||||
|
without_email:
|
||||||
|
en_construction: Le %{processed_at} ce dossier a été passé en construction
|
||||||
|
en_instruction: Le %{processed_at} ce dossier a été passé en instruction
|
||||||
|
accepte: Le %{processed_at} ce dossier a été accepté
|
||||||
|
refuse: Le %{processed_at} ce dossier a été refusé
|
||||||
|
classe_sans_suite: Le %{processed_at} ce dossier a été classé sans suite
|
||||||
|
with_email:
|
||||||
|
en_construction: Le %{processed_at}, %{email} a passé ce dossier en construction
|
||||||
|
en_instruction: Le %{processed_at}, %{email} a passé ce dossier en instruction
|
||||||
|
accepte: Le %{processed_at}, %{email} a accepté ce dossier
|
||||||
|
refuse: Le %{processed_at}, %{email} a refusé ce dossier
|
||||||
|
classe_sans_suite: Le %{processed_at}, %{email} a classé ce dossier sans suite
|
||||||
|
|
|
@ -43,4 +43,5 @@ fr:
|
||||||
L’autogestion des instructeurs permet aux instructeurs de gérer eux-mêmes la liste des instructeurs de la démarche.
|
L’autogestion des instructeurs permet aux instructeurs de gérer eux-mêmes la liste des instructeurs de la démarche.
|
||||||
button:
|
button:
|
||||||
routing_enable: Activer le routage
|
routing_enable: Activer le routage
|
||||||
|
routing_disable: Désactiver le routage
|
||||||
self_managment_toggle: Activer l’autogestion des instructeurs
|
self_managment_toggle: Activer l’autogestion des instructeurs
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
en:
|
en:
|
||||||
views:
|
views:
|
||||||
shared:
|
shared:
|
||||||
|
dossiers:
|
||||||
|
identite_entreprise:
|
||||||
|
warning_for_private_info: "The establishment %{etablissement} applied his right to not publish information regarding his identity. These informaiton won't be visible from instructor services"
|
||||||
|
avis:
|
||||||
|
demande_envoyee_le: "Feedback send at %{date}"
|
||||||
|
demande_revoquee_le: "Feedback revoked at %{date}"
|
||||||
|
reponse_donnee_le: "Response sent at %{date}"
|
||||||
|
en_attente: "Waiting for response"
|
||||||
france_connect_login:
|
france_connect_login:
|
||||||
title: "With FranceConnect"
|
title: "With FranceConnect"
|
||||||
description: "France connect is a solution proposed by the government to secure and simplify the connection to web services."
|
description: "France connect is a solution proposed by the government to secure and simplify the connection to web services."
|
||||||
|
@ -12,3 +20,12 @@ en:
|
||||||
already_user: "I already have an account"
|
already_user: "I already have an account"
|
||||||
create: 'Create an account'
|
create: 'Create an account'
|
||||||
signin: 'Sign in'
|
signin: 'Sign in'
|
||||||
|
commentaires:
|
||||||
|
destroy:
|
||||||
|
button: 'Destroy this message'
|
||||||
|
confirm: "Are you sure you want to destroy this message ?"
|
||||||
|
deleted_body: Message deleted
|
||||||
|
notice: 'Your message had been deleted'
|
||||||
|
alert_reasons:
|
||||||
|
acl: "Can not destroy message: it does not belong to you"
|
||||||
|
already_discarded: "Can not destroy message: it was already destroyed"
|
||||||
|
|
|
@ -20,3 +20,12 @@ fr:
|
||||||
already_user: 'J’ai déjà un compte'
|
already_user: 'J’ai déjà un compte'
|
||||||
create: 'Créer un compte'
|
create: 'Créer un compte'
|
||||||
signin: 'Connexion'
|
signin: 'Connexion'
|
||||||
|
commentaires:
|
||||||
|
destroy:
|
||||||
|
button: 'Supprimer le message'
|
||||||
|
confirm: "Êtes-vous sûr de vouloir supprimer ce message ?"
|
||||||
|
deleted_body: Message supprimé
|
||||||
|
notice: 'Votre message a été supprimé'
|
||||||
|
alert_reasons:
|
||||||
|
acl: "Impossible de supprimer le message, celui ci ne vous appartient pas"
|
||||||
|
already_discarded: "Ce message a déjà été supprimé"
|
||||||
|
|
|
@ -351,6 +351,8 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resources :dossiers, only: [:show], param: :dossier_id do
|
resources :dossiers, only: [:show], param: :dossier_id do
|
||||||
member do
|
member do
|
||||||
|
resources :commentaires, only: [:destroy]
|
||||||
|
|
||||||
get 'attestation'
|
get 'attestation'
|
||||||
get 'geo_data'
|
get 'geo_data'
|
||||||
get 'apercu_attestation'
|
get 'apercu_attestation'
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class AddDiscardedAtToCommentaires < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
add_column :commentaires, :discarded_at, :datetime
|
||||||
|
# add_index :commentaires, :discarded_at
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,8 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2021_11_04_102349) do
|
ActiveRecord::Schema.define(version: 2021_11_15_112933) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
enable_extension "unaccent"
|
enable_extension "unaccent"
|
||||||
|
@ -219,6 +218,7 @@ ActiveRecord::Schema.define(version: 2021_11_04_102349) do
|
||||||
t.bigint "user_id"
|
t.bigint "user_id"
|
||||||
t.bigint "instructeur_id"
|
t.bigint "instructeur_id"
|
||||||
t.bigint "expert_id"
|
t.bigint "expert_id"
|
||||||
|
t.datetime "discarded_at"
|
||||||
t.index ["dossier_id"], name: "index_commentaires_on_dossier_id"
|
t.index ["dossier_id"], name: "index_commentaires_on_dossier_id"
|
||||||
t.index ["expert_id"], name: "index_commentaires_on_expert_id"
|
t.index ["expert_id"], name: "index_commentaires_on_expert_id"
|
||||||
t.index ["instructeur_id"], name: "index_commentaires_on_instructeur_id"
|
t.index ["instructeur_id"], name: "index_commentaires_on_instructeur_id"
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
describe Instructeurs::CommentairesController, type: :controller do
|
||||||
|
let(:instructeur) { create(:instructeur) }
|
||||||
|
let(:procedure) { create(:procedure, :published, :for_individual, instructeurs: [instructeur]) }
|
||||||
|
let(:dossier) { create(:dossier, :en_construction, :with_individual, procedure: procedure) }
|
||||||
|
|
||||||
|
before { sign_in(instructeur.user) }
|
||||||
|
|
||||||
|
describe 'destroy' do
|
||||||
|
context 'when it works' do
|
||||||
|
let(:commentaire) { create(:commentaire, instructeur: instructeur, dossier: dossier) }
|
||||||
|
subject { delete :destroy, params: { dossier_id: dossier.id, procedure_id: procedure.id, id: commentaire.id } }
|
||||||
|
|
||||||
|
it 'redirect to dossier' do
|
||||||
|
expect(subject).to redirect_to(messagerie_instructeur_dossier_path(dossier.procedure, dossier))
|
||||||
|
end
|
||||||
|
it 'flash success' do
|
||||||
|
subject
|
||||||
|
expect(flash[:notice]).to eq(I18n.t('views.shared.commentaires.destroy.notice'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when dossier had been discarded' do
|
||||||
|
let(:commentaire) { create(:commentaire, instructeur: instructeur, dossier: dossier, discarded_at: 2.hours.ago) }
|
||||||
|
subject { delete :destroy, params: { dossier_id: dossier.id, procedure_id: procedure.id, id: commentaire.id } }
|
||||||
|
|
||||||
|
it 'redirect to dossier' do
|
||||||
|
expect(subject).to redirect_to(messagerie_instructeur_dossier_path(dossier.procedure, dossier))
|
||||||
|
end
|
||||||
|
it 'flash success' do
|
||||||
|
subject
|
||||||
|
expect(flash[:alert]).to eq(I18n.t('views.shared.commentaires.destroy.alert_reasons.already_discarded'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -382,6 +382,11 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#messagerie' do
|
||||||
|
subject { get :messagerie, params: { procedure_id: procedure.id, dossier_id: dossier.id } }
|
||||||
|
it { expect(response).to have_http_status(:ok) }
|
||||||
|
end
|
||||||
|
|
||||||
describe "#create_commentaire" do
|
describe "#create_commentaire" do
|
||||||
let(:saved_commentaire) { dossier.commentaires.first }
|
let(:saved_commentaire) { dossier.commentaires.first }
|
||||||
let(:body) { "avant\napres" }
|
let(:body) { "avant\napres" }
|
||||||
|
|
|
@ -9,7 +9,6 @@ describe NewAdministrateur::ProceduresController, type: :controller do
|
||||||
let(:direction) { 'Direction de test' }
|
let(:direction) { 'Direction de test' }
|
||||||
let(:cadre_juridique) { 'cadre juridique' }
|
let(:cadre_juridique) { 'cadre juridique' }
|
||||||
let(:duree_conservation_dossiers_dans_ds) { 3 }
|
let(:duree_conservation_dossiers_dans_ds) { 3 }
|
||||||
let(:duree_conservation_dossiers_hors_ds) { 6 }
|
|
||||||
let(:monavis_embed) { nil }
|
let(:monavis_embed) { nil }
|
||||||
let(:lien_site_web) { 'http://mon-site.gouv.fr' }
|
let(:lien_site_web) { 'http://mon-site.gouv.fr' }
|
||||||
|
|
||||||
|
@ -33,7 +32,6 @@ describe NewAdministrateur::ProceduresController, type: :controller do
|
||||||
direction: direction,
|
direction: direction,
|
||||||
cadre_juridique: cadre_juridique,
|
cadre_juridique: cadre_juridique,
|
||||||
duree_conservation_dossiers_dans_ds: duree_conservation_dossiers_dans_ds,
|
duree_conservation_dossiers_dans_ds: duree_conservation_dossiers_dans_ds,
|
||||||
duree_conservation_dossiers_hors_ds: duree_conservation_dossiers_hors_ds,
|
|
||||||
monavis_embed: monavis_embed,
|
monavis_embed: monavis_embed,
|
||||||
lien_site_web: lien_site_web
|
lien_site_web: lien_site_web
|
||||||
}
|
}
|
||||||
|
@ -164,7 +162,6 @@ describe NewAdministrateur::ProceduresController, type: :controller do
|
||||||
it { expect(subject.direction).to eq(direction) }
|
it { expect(subject.direction).to eq(direction) }
|
||||||
it { expect(subject.administrateurs).to eq([admin]) }
|
it { expect(subject.administrateurs).to eq([admin]) }
|
||||||
it { expect(subject.duree_conservation_dossiers_dans_ds).to eq(duree_conservation_dossiers_dans_ds) }
|
it { expect(subject.duree_conservation_dossiers_dans_ds).to eq(duree_conservation_dossiers_dans_ds) }
|
||||||
it { expect(subject.duree_conservation_dossiers_hors_ds).to eq(duree_conservation_dossiers_hors_ds) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to redirect_to(champs_admin_procedure_path(Procedure.last)) }
|
it { is_expected.to redirect_to(champs_admin_procedure_path(Procedure.last)) }
|
||||||
|
@ -234,7 +231,6 @@ describe NewAdministrateur::ProceduresController, type: :controller do
|
||||||
let(:organisation) { 'plop' }
|
let(:organisation) { 'plop' }
|
||||||
let(:direction) { 'plap' }
|
let(:direction) { 'plap' }
|
||||||
let(:duree_conservation_dossiers_dans_ds) { 7 }
|
let(:duree_conservation_dossiers_dans_ds) { 7 }
|
||||||
let(:duree_conservation_dossiers_hors_ds) { 5 }
|
|
||||||
|
|
||||||
before { update_procedure }
|
before { update_procedure }
|
||||||
|
|
||||||
|
@ -246,7 +242,6 @@ describe NewAdministrateur::ProceduresController, type: :controller do
|
||||||
it { expect(subject.organisation).to eq(organisation) }
|
it { expect(subject.organisation).to eq(organisation) }
|
||||||
it { expect(subject.direction).to eq(direction) }
|
it { expect(subject.direction).to eq(direction) }
|
||||||
it { expect(subject.duree_conservation_dossiers_dans_ds).to eq(duree_conservation_dossiers_dans_ds) }
|
it { expect(subject.duree_conservation_dossiers_dans_ds).to eq(duree_conservation_dossiers_dans_ds) }
|
||||||
it { expect(subject.duree_conservation_dossiers_hors_ds).to eq(duree_conservation_dossiers_hors_ds) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to redirect_to(edit_admin_procedure_path id: procedure.id) }
|
it { is_expected.to redirect_to(edit_admin_procedure_path id: procedure.id) }
|
||||||
|
|
|
@ -1,30 +1,16 @@
|
||||||
RSpec.describe ConservationDeDonneesHelper, type: :helper do
|
RSpec.describe ConservationDeDonneesHelper, type: :helper do
|
||||||
let(:procedure) { build(:procedure, duree_conservation_dossiers_dans_ds: dans_ds, duree_conservation_dossiers_hors_ds: hors_ds) }
|
let(:procedure) { build(:procedure, duree_conservation_dossiers_dans_ds: dans_ds) }
|
||||||
|
|
||||||
describe "politiques_conservation_de_donnees" do
|
describe "politiques_conservation_de_donnees" do
|
||||||
subject { politiques_conservation_de_donnees(procedure) }
|
subject { politiques_conservation_de_donnees(procedure) }
|
||||||
|
|
||||||
context "when both retention times are set" do
|
context "when retention time is set" do
|
||||||
let(:dans_ds) { 3 }
|
let(:dans_ds) { 3 }
|
||||||
let(:hors_ds) { 6 }
|
let(:hors_ds) { 6 }
|
||||||
|
|
||||||
it { is_expected.to eq(["Dans #{APPLICATION_NAME} : 3 mois", "Par l’administration : 6 mois"]) }
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when only in-app retention time is set" do
|
|
||||||
let(:dans_ds) { 3 }
|
|
||||||
let(:hors_ds) { nil }
|
|
||||||
|
|
||||||
it { is_expected.to eq(["Dans #{APPLICATION_NAME} : 3 mois"]) }
|
it { is_expected.to eq(["Dans #{APPLICATION_NAME} : 3 mois"]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when only out of app retention time is set" do
|
|
||||||
let(:dans_ds) { nil }
|
|
||||||
let(:hors_ds) { 6 }
|
|
||||||
|
|
||||||
it { is_expected.to eq(["Par l’administration : 6 mois"]) }
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when the retention time is not set" do
|
context "when the retention time is not set" do
|
||||||
let(:dans_ds) { nil }
|
let(:dans_ds) { nil }
|
||||||
let(:hors_ds) { nil }
|
let(:hors_ds) { nil }
|
||||||
|
|
|
@ -28,8 +28,8 @@ RSpec.describe DossierMailer, type: :mailer do
|
||||||
|
|
||||||
describe '.notify_new_answer with dossier brouillon' do
|
describe '.notify_new_answer with dossier brouillon' do
|
||||||
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
|
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
|
||||||
|
let(:commentaire) { create(:commentaire, dossier: dossier) }
|
||||||
subject { described_class.notify_new_answer(dossier) }
|
subject { described_class.with(commentaire: commentaire).notify_new_answer }
|
||||||
|
|
||||||
it { expect(subject.subject).to include("Nouveau message") }
|
it { expect(subject.subject).to include("Nouveau message") }
|
||||||
it { expect(subject.subject).to include(dossier.id.to_s) }
|
it { expect(subject.subject).to include(dossier.id.to_s) }
|
||||||
|
@ -40,8 +40,8 @@ RSpec.describe DossierMailer, type: :mailer do
|
||||||
|
|
||||||
describe '.notify_new_answer with dossier en construction' do
|
describe '.notify_new_answer with dossier en construction' do
|
||||||
let(:dossier) { create(:dossier, state: "en_construction", procedure: build(:simple_procedure)) }
|
let(:dossier) { create(:dossier, state: "en_construction", procedure: build(:simple_procedure)) }
|
||||||
|
let(:commentaire) { create(:commentaire, dossier: dossier) }
|
||||||
subject { described_class.notify_new_answer(dossier) }
|
subject { described_class.with(commentaire: commentaire).notify_new_answer }
|
||||||
|
|
||||||
it { expect(subject.subject).to include("Nouveau message") }
|
it { expect(subject.subject).to include("Nouveau message") }
|
||||||
it { expect(subject.subject).to include(dossier.id.to_s) }
|
it { expect(subject.subject).to include(dossier.id.to_s) }
|
||||||
|
@ -50,6 +50,15 @@ RSpec.describe DossierMailer, type: :mailer do
|
||||||
it_behaves_like 'a dossier notification'
|
it_behaves_like 'a dossier notification'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '.notify_new_answer with commentaire discarded' do
|
||||||
|
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
|
||||||
|
let(:commentaire) { create(:commentaire, dossier: dossier, discarded_at: 2.minutes.ago) }
|
||||||
|
|
||||||
|
subject { described_class.with(commentaire: commentaire).notify_new_answer }
|
||||||
|
|
||||||
|
it { expect(subject.perform_deliveries).to be_falsy }
|
||||||
|
end
|
||||||
|
|
||||||
describe '.notify_deletion_to_user' do
|
describe '.notify_deletion_to_user' do
|
||||||
let(:deleted_dossier) { build(:deleted_dossier) }
|
let(:deleted_dossier) { build(:deleted_dossier) }
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,12 @@ describe Commentaire do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "sent_by?" do
|
||||||
|
let(:commentaire) { build(:commentaire, instructeur: build(:instructeur)) }
|
||||||
|
subject { commentaire.sent_by?(nil) }
|
||||||
|
it { is_expected.to be_falsy }
|
||||||
|
end
|
||||||
|
|
||||||
describe "#redacted_email" do
|
describe "#redacted_email" do
|
||||||
subject { commentaire.redacted_email }
|
subject { commentaire.redacted_email }
|
||||||
|
|
||||||
|
@ -80,8 +86,8 @@ describe Commentaire do
|
||||||
context "with a commentaire created by a instructeur" do
|
context "with a commentaire created by a instructeur" do
|
||||||
let(:commentaire) { CommentaireService.build(instructeur, dossier, body: "Mon commentaire") }
|
let(:commentaire) { CommentaireService.build(instructeur, dossier, body: "Mon commentaire") }
|
||||||
|
|
||||||
it "calls notify_user" do
|
it "calls notify_user with delay so instructeur can destroy his comment in case of failure" do
|
||||||
expect(commentaire).to receive(:notify_user)
|
expect(commentaire).to receive(:notify_user).with(wait: 5.minutes)
|
||||||
commentaire.save
|
commentaire.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -90,7 +96,7 @@ describe Commentaire do
|
||||||
let(:commentaire) { CommentaireService.build(expert, dossier, body: "Mon commentaire") }
|
let(:commentaire) { CommentaireService.build(expert, dossier, body: "Mon commentaire") }
|
||||||
|
|
||||||
it "calls notify_user" do
|
it "calls notify_user" do
|
||||||
expect(commentaire).to receive(:notify_user)
|
expect(commentaire).to receive(:notify_user).with(no_args)
|
||||||
commentaire.save
|
commentaire.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -99,7 +105,7 @@ describe Commentaire do
|
||||||
let(:commentaire) { CommentaireService.build_with_email(CONTACT_EMAIL, dossier, body: "Mon commentaire") }
|
let(:commentaire) { CommentaireService.build_with_email(CONTACT_EMAIL, dossier, body: "Mon commentaire") }
|
||||||
|
|
||||||
it "does not call notify_user" do
|
it "does not call notify_user" do
|
||||||
expect(commentaire).not_to receive(:notify_user)
|
expect(commentaire).not_to receive(:notify_user).with(no_args)
|
||||||
commentaire.save
|
commentaire.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -426,13 +426,14 @@ describe User, type: :model do
|
||||||
|
|
||||||
context 'and the old account has some stuff' do
|
context 'and the old account has some stuff' do
|
||||||
let!(:dossier) { create(:dossier, user: old_user) }
|
let!(:dossier) { create(:dossier, user: old_user) }
|
||||||
|
let!(:hidden_dossier) { create(:dossier, user: old_user, hidden_at: Time.zone.now) }
|
||||||
let!(:invite) { create(:invite, user: old_user) }
|
let!(:invite) { create(:invite, user: old_user) }
|
||||||
let!(:merge_log) { MergeLog.create(user: old_user, from_user_id: 1, from_user_email: 'a') }
|
let!(:merge_log) { MergeLog.create(user: old_user, from_user_id: 1, from_user_email: 'a') }
|
||||||
|
|
||||||
it 'transfers the dossier' do
|
it 'transfers the dossier' do
|
||||||
subject
|
subject
|
||||||
|
|
||||||
expect(targeted_user.dossiers).to match([dossier])
|
expect(targeted_user.dossiers.with_discarded).to match([dossier, hidden_dossier])
|
||||||
expect(targeted_user.invites).to match([invite])
|
expect(targeted_user.invites).to match([invite])
|
||||||
expect(targeted_user.merge_logs.first).to eq(merge_log)
|
expect(targeted_user.merge_logs.first).to eq(merge_log)
|
||||||
|
|
||||||
|
|
|
@ -46,5 +46,44 @@ describe 'shared/dossiers/messages/message.html.haml', type: :view do
|
||||||
it { is_expected.not_to have_text(instructeur.email) }
|
it { is_expected.not_to have_text(instructeur.email) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'delete message button for instructeur' do
|
||||||
|
let(:instructeur) { create(:instructeur) }
|
||||||
|
let(:procedure) { create(:procedure) }
|
||||||
|
let(:dossier) { create(:dossier, :en_construction, commentaires: [commentaire], procedure: procedure) }
|
||||||
|
subject { render 'shared/dossiers/messages/message.html.haml', commentaire: commentaire, messagerie_seen_at: seen_at, connected_user: instructeur, show_reply_button: true }
|
||||||
|
let(:form_url) { instructeur_commentaire_path(commentaire.dossier.procedure, commentaire.dossier, commentaire) }
|
||||||
|
|
||||||
|
context 'on a procedure where commentaire had been written by connected instructeur' do
|
||||||
|
let(:commentaire) { create(:commentaire, instructeur: instructeur, body: 'Second message') }
|
||||||
|
|
||||||
|
it { is_expected.to have_selector("form[action=\"#{form_url}\"]") }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on a procedure where commentaire had been written by connected instructeur and discarded' do
|
||||||
|
let(:commentaire) { create(:commentaire, instructeur: instructeur, body: 'Second message', discarded_at: 2.days.ago) }
|
||||||
|
|
||||||
|
it { is_expected.not_to have_selector("form[action=\"#{form_url}\"]") }
|
||||||
|
it { is_expected.not_to have_selector(".rich-text", text: I18n.t(t('views.shared.commentaires.destroy.deleted_body'))) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on a procedure where commentaire had been written by connected an user' do
|
||||||
|
let(:commentaire) { create(:commentaire, email: create(:user).email, body: 'Second message') }
|
||||||
|
|
||||||
|
it { is_expected.not_to have_selector("form[action=\"#{form_url}\"]") }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on a procedure where commentaire had been written by connected an expert' do
|
||||||
|
let(:commentaire) { create(:commentaire, expert: create(:expert), body: 'Second message') }
|
||||||
|
|
||||||
|
it { is_expected.not_to have_selector("form[action=\"#{form_url}\"]") }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on a procedure where commentaire had been written another instructeur' do
|
||||||
|
let(:commentaire) { create(:commentaire, instructeur: create(:instructeur), body: 'Second message') }
|
||||||
|
|
||||||
|
it { is_expected.not_to have_selector("form[action=\"#{form_url}\"]") }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue