commit
a66bef8379
39 changed files with 397 additions and 139 deletions
|
@ -80,8 +80,12 @@ module Gestionnaires
|
|||
end
|
||||
|
||||
def passer_en_instruction
|
||||
if dossier.en_instruction?
|
||||
flash.notice = 'Le dossier est déjà en instruction.'
|
||||
else
|
||||
dossier.passer_en_instruction!(current_gestionnaire)
|
||||
flash.notice = 'Dossier passé en instruction.'
|
||||
end
|
||||
|
||||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
||||
end
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
module NewAdministrateur
|
||||
class ProfilController < AdministrateurController
|
||||
def show
|
||||
end
|
||||
|
||||
def renew_api_token
|
||||
@token = current_administrateur.renew_api_token
|
||||
flash.now.notice = 'Votre jeton a été regénéré.'
|
||||
render :show
|
||||
end
|
||||
end
|
||||
end
|
|
@ -64,7 +64,7 @@ class SupportController < ApplicationController
|
|||
file: params[:file],
|
||||
body: "[#{params[:subject]}]<br><br>#{params[:text]}"
|
||||
}
|
||||
commentaire = CommentaireService.build_with_email(email, dossier, attributes)
|
||||
commentaire = CommentaireService.build(current_user, dossier, attributes)
|
||||
commentaire.save!
|
||||
end
|
||||
|
||||
|
@ -82,7 +82,7 @@ class SupportController < ApplicationController
|
|||
end
|
||||
|
||||
def direct_message?
|
||||
user_signed_in? && params[:type] == Helpscout::FormAdapter::TYPE_INSTRUCTION && dossier.present? && !dossier.brouillon?
|
||||
user_signed_in? && params[:type] == Helpscout::FormAdapter::TYPE_INSTRUCTION && dossier.present? && dossier.messagerie_available?
|
||||
end
|
||||
|
||||
def dossier
|
||||
|
|
31
app/controllers/users/profil_controller.rb
Normal file
31
app/controllers/users/profil_controller.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Users
|
||||
class ProfilController < UserController
|
||||
def show
|
||||
end
|
||||
|
||||
def renew_api_token
|
||||
@token = current_administrateur.renew_api_token
|
||||
flash.now.notice = 'Votre jeton a été regénéré.'
|
||||
render :show
|
||||
end
|
||||
|
||||
def update_email
|
||||
if @current_user.update(update_email_params)
|
||||
flash.notice = t('devise.registrations.update_needs_confirmation')
|
||||
# to avoid leaking who has signed in
|
||||
elsif @current_user.errors&.details&.dig(:email)&.any? { |e| e[:error] == :taken }
|
||||
flash.notice = t('devise.registrations.update_needs_confirmation')
|
||||
else
|
||||
flash.alert = @current_user.errors.full_messages
|
||||
end
|
||||
|
||||
redirect_to profil_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_email_params
|
||||
params.require(:user).permit(:email)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,12 +1,12 @@
|
|||
module CommentaireHelper
|
||||
def commentaire_is_from_me_class(commentaire, connected_user)
|
||||
if commentaire_is_from_me(commentaire, connected_user)
|
||||
if commentaire.sent_by?(connected_user)
|
||||
"from-me"
|
||||
end
|
||||
end
|
||||
|
||||
def commentaire_answer_action(commentaire, connected_user)
|
||||
if commentaire_is_from_me(commentaire, connected_user)
|
||||
if commentaire.sent_by?(connected_user)
|
||||
"Envoyer un message à l’instructeur"
|
||||
else
|
||||
"Répondre dans la messagerie"
|
||||
|
@ -22,10 +22,4 @@ module CommentaireHelper
|
|||
template = is_current_year ? :message_date : :message_date_with_year
|
||||
I18n.l(commentaire.created_at, format: template)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def commentaire_is_from_me(commentaire, connected_user)
|
||||
commentaire.email == connected_user.email
|
||||
end
|
||||
end
|
||||
|
|
11
app/helpers/tableau_de_bord_helper.rb
Normal file
11
app/helpers/tableau_de_bord_helper.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
module TableauDeBordHelper
|
||||
def tableau_de_bord_helper_path
|
||||
if current_administrateur.present?
|
||||
admin_procedures_path
|
||||
elsif current_gestionnaire.present?
|
||||
gestionnaire_procedures_path
|
||||
else
|
||||
dossiers_path
|
||||
end
|
||||
end
|
||||
end
|
|
@ -7,6 +7,7 @@ class Commentaire < ApplicationRecord
|
|||
mount_uploader :file, CommentaireFileUploader
|
||||
validates :file, file_size: { maximum: 20.megabytes, message: "La taille du fichier doit être inférieure à 20 Mo" }
|
||||
validate :is_virus_free?
|
||||
validate :messagerie_available?, on: :create
|
||||
validates :body, presence: { message: "Votre message ne peut être vide" }
|
||||
|
||||
default_scope { order(created_at: :asc) }
|
||||
|
@ -14,10 +15,6 @@ class Commentaire < ApplicationRecord
|
|||
|
||||
after_create :notify
|
||||
|
||||
def self.columns
|
||||
super.reject { |c| c.name == "champ" }
|
||||
end
|
||||
|
||||
def email
|
||||
if user
|
||||
user.email
|
||||
|
@ -29,15 +26,26 @@ class Commentaire < ApplicationRecord
|
|||
end
|
||||
|
||||
def header
|
||||
"#{sender}, #{I18n.l(created_at, format: '%d %b %Y %H:%M')}"
|
||||
"#{redacted_email}, #{I18n.l(created_at, format: '%d %b %Y %H:%M')}"
|
||||
end
|
||||
|
||||
def sender
|
||||
if email.present?
|
||||
email.split('@').first
|
||||
def redacted_email
|
||||
if gestionnaire.present?
|
||||
gestionnaire.email.split('@').first
|
||||
else
|
||||
email
|
||||
end
|
||||
end
|
||||
|
||||
def sent_by_system?
|
||||
[CONTACT_EMAIL, OLD_CONTACT_EMAIL].include?(email) &&
|
||||
user.nil? && gestionnaire.nil?
|
||||
end
|
||||
|
||||
def sent_by?(someone)
|
||||
email == someone.email
|
||||
end
|
||||
|
||||
def file_url
|
||||
if Flipflop.remote_storage?
|
||||
RemoteDownloader.new(file.path).url
|
||||
|
@ -71,4 +79,11 @@ class Commentaire < ApplicationRecord
|
|||
errors.add(:file, "Virus détecté dans le fichier joint, merci de changer de fichier")
|
||||
end
|
||||
end
|
||||
|
||||
def messagerie_available?
|
||||
return if sent_by_system?
|
||||
if dossier.present? && !dossier.messagerie_available?
|
||||
errors.add(:dossier, "Il n’est pas possible d’envoyer un message sur un dossier archivé ou en brouillon")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -445,8 +445,8 @@ class Dossier < ApplicationRecord
|
|||
['Archivé', :archived],
|
||||
['État du dossier', I18n.t(state, scope: [:activerecord, :attributes, :dossier, :state])],
|
||||
['Dernière mise à jour le', :updated_at],
|
||||
['Passé en construction le', :en_instruction_at],
|
||||
['Passé en instruction le', :en_construction_at],
|
||||
['Passé en construction le', :en_construction_at],
|
||||
['Passé en instruction le', :en_instruction_at],
|
||||
['Traité le', :processed_at],
|
||||
['Motivation de la décision', :motivation],
|
||||
['Instructeurs', followers_gestionnaires.map(&:email).join(' ')]
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
require Rails.root.join('lib', 'percentile')
|
||||
|
||||
class Procedure < ApplicationRecord
|
||||
self.ignored_columns = [:administrateur_id]
|
||||
|
||||
MAX_DUREE_CONSERVATION = 36
|
||||
|
||||
has_many :types_de_piece_justificative, -> { ordered }, inverse_of: :procedure, dependent: :destroy
|
||||
|
|
|
@ -59,8 +59,8 @@ class AdministrateurUsageStatisticsService
|
|||
.max || 0,
|
||||
nb_dossiers_traite: nb_dossiers_by_synthetic_state['termine'],
|
||||
nb_dossiers_dossier_en_instruction: nb_dossiers_by_synthetic_state['en_instruction'],
|
||||
admin_roi_low: nb_dossiers_roi * 7.04,
|
||||
admin_roi_high: nb_dossiers_roi * 17.25
|
||||
admin_roi_low: nb_dossiers_roi * 7,
|
||||
admin_roi_high: nb_dossiers_roi * 17
|
||||
}
|
||||
|
||||
if administrateur.current_sign_in_at.present?
|
||||
|
|
|
@ -1,17 +1,36 @@
|
|||
require 'prawn/measurement_extensions'
|
||||
|
||||
prawn_document(margin: [50, 100, 20, 100]) do |pdf|
|
||||
#----- A4 page size
|
||||
page_size = 'A4'
|
||||
page_height = 842
|
||||
page_width = 595
|
||||
|
||||
#----- margins
|
||||
body_width = 400
|
||||
top_margin = 50
|
||||
bottom_margin = 20
|
||||
footer_height = top_margin - bottom_margin
|
||||
|
||||
right_margin = (page_width - body_width)/2
|
||||
left_margin = right_margin
|
||||
|
||||
#----- size of images
|
||||
max_logo_width = body_width
|
||||
max_logo_height = 50.mm
|
||||
max_signature_size = 50.mm
|
||||
|
||||
prawn_document(margin: [top_margin, right_margin, bottom_margin, left_margin], page_size: page_size) do |pdf|
|
||||
pdf.font_families.update( 'liberation serif' => { normal: Rails.root.join('lib/prawn/fonts/liberation_serif/LiberationSerif-Regular.ttf' )})
|
||||
pdf.font 'liberation serif'
|
||||
|
||||
grey = '555555'
|
||||
black = '333333'
|
||||
max_logo_size = 40.mm
|
||||
max_signature_size = 40.mm
|
||||
|
||||
pdf.bounding_box([0, pdf.cursor], width: 400, height: 650) do
|
||||
body_height = pdf.cursor - footer_height
|
||||
|
||||
pdf.bounding_box([0, pdf.cursor], width: body_width, height: body_height) do
|
||||
if @logo.present?
|
||||
pdf.image StringIO.new(@logo.read), fit: [max_logo_size , max_logo_size], position: :center
|
||||
pdf.image StringIO.new(@logo.read), fit: [max_logo_width , max_logo_height], position: :center
|
||||
end
|
||||
|
||||
pdf.fill_color grey
|
||||
|
@ -31,7 +50,7 @@ prawn_document(margin: [50, 100, 20, 100]) do |pdf|
|
|||
end
|
||||
|
||||
pdf.repeat(:all) do
|
||||
pdf.move_cursor_to 20
|
||||
pdf.move_cursor_to footer_height - 10
|
||||
pdf.fill_color grey
|
||||
pdf.text @footer, align: :center, size: 8
|
||||
end
|
||||
|
|
|
@ -97,14 +97,25 @@
|
|||
- if !@procedure.locked?
|
||||
.row
|
||||
.col-md-6
|
||||
%h4 Particuliers
|
||||
%h4 À qui s’adresse ma démarche ?
|
||||
.checkbox
|
||||
%label
|
||||
= f.check_box :for_individual
|
||||
Cette démarche s'adresse à un public qui
|
||||
= f.radio_button :for_individual, 1, :checked => true
|
||||
%b Ma démarche s’adresse à un particulier
|
||||
|
||||
%p
|
||||
En choisissant cette option, l’usager devra renseigner son nom et prénom avant d’accéder au formulaire
|
||||
|
||||
.checkbox
|
||||
%label
|
||||
= f.radio_button :for_individual, 0, :checked => false
|
||||
%b Ma démarche s’adresse à une personne morale
|
||||
|
||||
%p
|
||||
En choisissant cette option, l’usager devra renseigner son n° SIRET. Grâce à l’API Entreprise, seront alors automatiquement remontées les informations sur la personne morale type raison sociale ou adresse du siège social.
|
||||
|
||||
%b
|
||||
ne possède pas (ou pas encore) de numéro SIRET,
|
||||
qui doivent donc s'identifier en tant que personne physique.
|
||||
Si votre démarche s’adresse indifféremment à une personne morale ou un particulier choisissez l'option "particuliers". Vous pourrez utilisez le champ SIRET directement dans le formulaire.
|
||||
|
||||
%ul#individual-with-siret
|
||||
%li
|
||||
|
|
|
@ -1,10 +1,22 @@
|
|||
- content_for(:title, 'Activez votre compte')
|
||||
-# ugly hack to know if the mail is creation confirmation or a password change confirmation
|
||||
- if @user.unconfirmed_email.nil?
|
||||
- content_for(:title, 'Activez votre compte')
|
||||
|
||||
%p
|
||||
%p
|
||||
Bonjour,
|
||||
|
||||
%p
|
||||
%p
|
||||
Pour activer votre compte sur demarches-simplifiees.fr, veuillez cliquer sur le lien suivant :
|
||||
= link_to(confirmation_url(@user, confirmation_token: @token), confirmation_url(@user, confirmation_token: @token))
|
||||
|
||||
- else
|
||||
- content_for(:title, "Changement d'adresse email")
|
||||
|
||||
%p
|
||||
Bonjour,
|
||||
|
||||
%p
|
||||
Pour confirmer votre changement d'adresse email, veuillez cliquer sur le lien suivant :
|
||||
= link_to(confirmation_url(@user, confirmation_token: @token), confirmation_url(@user, confirmation_token: @token))
|
||||
|
||||
= render partial: "layouts/mailers/signature"
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
= link_to admin_procedures_path, class: "menu-item menu-link" do
|
||||
= image_tag "icons/switch-profile.svg"
|
||||
Passer en administrateur
|
||||
%li
|
||||
= link_to profil_path, class: "menu-item menu-link" do
|
||||
= image_tag "icons/switch-profile.svg"
|
||||
Voir mon profil
|
||||
|
||||
%li
|
||||
= link_to destroy_user_session_path, method: :delete, class: "menu-item menu-link" do
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#navbar-body
|
||||
.row
|
||||
%div{ style: "vertical-align: middle;float:left;position:absolute;line-height: 60px;z-index:2;" }
|
||||
Besoin d'aide? <a href="tel:#{CONTACT_PHONE}">#{CONTACT_PHONE}</a> ou <a href="#{contact_admin_path}" target="_blank" rel="noopener">email</a> ou <a target="_blank" rel="noopener" href="https://calendly.com/demarches-simplifiees/accompagnement-administrateur-demarches-simplifiees-fr">prenez rendez-vous avec nous</a>
|
||||
👉 Besoin d'aide? Contactez-nous par <a style="cursor:hand" onclick="$crisp.push(['do', 'chat:open'])">chat</a>, <a href="#{contact_admin_path}" target="_blank" rel="noopener">email</a> ou <a target="_blank" rel="noopener" href="https://calendly.com/demarches-simplifiees/accompagnement-administrateur-demarches-simplifiees-fr">prenez rendez-vous avec nous</a>.
|
||||
-# BEST WTF EVER
|
||||
-# this begin rescue hides potentials bugs by displaying another navbar
|
||||
- begin
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
</header>
|
||||
|
||||
<p class="main-content__header">
|
||||
Plus de 1000 dossiers et "le plus vite possible" 👉 c'est un VIP ❤️. Appelez-le 📞 pour répondre à ses questions.
|
||||
</p>
|
||||
<% if @pending_demandes.present? %>
|
||||
<section class="main-content__body main-content__body--flush">
|
||||
<table>
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
= render partial: 'new_administrateur/breadcrumbs',
|
||||
locals: { steps: [link_to('Tableau de bord', admin_procedures_path),
|
||||
'Profil'] }
|
||||
|
||||
#profil-page.container
|
||||
%h1 Profil
|
||||
|
||||
.card
|
||||
.card-title Jeton d'identification de l'API (token)
|
||||
%p Ce jeton est nécessaire pour effectuer des appels vers l'API de demarches-simplifiees.fr.
|
||||
|
||||
- if defined?(@token)
|
||||
%p Jeton : <b>#{@token}</b>
|
||||
%p Pour des raisons de sécurité, ce jeton ne sera plus ré-affiché, notez-le bien.
|
||||
|
||||
- else
|
||||
%p Pour des raisons de sécurité, nous ne pouvons vous l'afficher que lors de sa génération.
|
||||
%p Attention, si vous avez déjà des applications qui utilisent votre jeton, le regénérer bloquera leurs accès à l'API.
|
||||
|
||||
= link_to "Regénérer et afficher mon jeton",
|
||||
renew_api_token_path,
|
||||
method: :post,
|
||||
class: "button primary",
|
||||
data: { confirm: "Confirmez-vous la regénération de votre jeton ? Les applications qui l'utilisent actuellement seront bloquées.",
|
||||
disable: true }
|
|
@ -4,7 +4,7 @@
|
|||
%li.message{ class: commentaire_is_from_me_class(commentaire, connected_user) }
|
||||
= render partial: "shared/dossiers/messages/message", locals: { commentaire: commentaire, connected_user: connected_user, messagerie_seen_at: messagerie_seen_at }
|
||||
|
||||
- if dossier.archived?
|
||||
= render partial: "shared/dossiers/messages/messagerie_disabled", locals: { service: dossier.procedure.service }
|
||||
- else
|
||||
- if dossier.messagerie_available?
|
||||
= render partial: "shared/dossiers/messages/form", locals: { commentaire: new_commentaire, form_url: form_url }
|
||||
- else
|
||||
= render partial: "shared/dossiers/messages/messagerie_disabled", locals: { service: dossier.procedure.service }
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
- case commentaire.email
|
||||
- when connected_user.email
|
||||
= image_tag('icons/account-circle.svg', class: 'person-icon')
|
||||
- when OLD_CONTACT_EMAIL
|
||||
- when CONTACT_EMAIL
|
||||
- if commentaire.sent_by_system?
|
||||
= image_tag('icons/mail.svg', class: 'person-icon')
|
||||
- elsif commentaire.sent_by?(connected_user)
|
||||
= image_tag('icons/account-circle.svg', class: 'person-icon')
|
||||
- else
|
||||
= image_tag('icons/blue-person.svg', class: 'person-icon')
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
- case commentaire.email
|
||||
- when connected_user.email
|
||||
Vous
|
||||
- when OLD_CONTACT_EMAIL
|
||||
- when CONTACT_EMAIL
|
||||
- if commentaire.sent_by_system?
|
||||
Email automatique
|
||||
- elsif commentaire.sent_by?(connected_user)
|
||||
Vous
|
||||
- else
|
||||
= commentaire.sender
|
||||
= commentaire.redacted_email
|
||||
|
|
39
app/views/users/profil/show.html.haml
Normal file
39
app/views/users/profil/show.html.haml
Normal file
|
@ -0,0 +1,39 @@
|
|||
= render partial: 'new_administrateur/breadcrumbs',
|
||||
locals: { steps: [link_to('Tableau de bord', tableau_de_bord_helper_path),
|
||||
'Profil'] }
|
||||
|
||||
#profil-page.container
|
||||
%h1 Profil
|
||||
|
||||
.card
|
||||
.card-title Coordonnées
|
||||
%p Votre email est actuellement #{current_user.email}
|
||||
- if current_user.unconfirmed_email.present?
|
||||
%p
|
||||
Un email a été envoyé à #{current_user.unconfirmed_email}.
|
||||
%br
|
||||
Merci de vérifier vos emails et de cliquer sur le lien d’activation pour finaliser la validation de votre nouvelle adresse.
|
||||
|
||||
= 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.submit "Changer mon adresse", class: 'button primary'
|
||||
|
||||
- if current_administrateur.present?
|
||||
.card
|
||||
.card-title Jeton d’identification de l’API (token)
|
||||
%p Ce jeton est nécessaire pour effectuer des appels vers l’API de demarches-simplifiees.fr.
|
||||
|
||||
- if defined?(@token)
|
||||
%p Jeton : <b>#{@token}</b>
|
||||
%p Pour des raisons de sécurité, ce jeton ne sera plus ré-affiché, notez-le bien.
|
||||
|
||||
- else
|
||||
%p Pour des raisons de sécurité, nous ne pouvons vous l’afficher que lors de sa génération.
|
||||
%p Attention, si vous avez déjà des applications qui utilisent votre jeton, le regénérer bloquera leurs accès à l’API.
|
||||
|
||||
= link_to "Regénérer et afficher mon jeton",
|
||||
renew_api_token_path,
|
||||
method: :post,
|
||||
class: "button primary",
|
||||
data: { confirm: "Confirmez-vous la regénération de votre jeton ? Les applications qui l’utilisent actuellement seront bloquées.",
|
||||
disable: true }
|
|
@ -121,7 +121,7 @@ Devise.setup do |config|
|
|||
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
||||
# db field (see migrations). Until confirmed, new email is stored in
|
||||
# unconfirmed_email column, and copied to email column on successful confirmation.
|
||||
config.reconfirmable = false
|
||||
config.reconfirmable = true
|
||||
|
||||
# Defines which key will be used when confirming an account
|
||||
# config.confirmation_keys = [ :email ]
|
||||
|
|
|
@ -42,7 +42,7 @@ fr:
|
|||
signed_up_but_inactive: "Vous êtes bien enregistré. Vous ne pouvez cependant pas vous connecter car votre compte n'est pas encore activé."
|
||||
signed_up_but_locked: "Vous êtes bien enregistré. Vous ne pouvez cependant pas vous connecter car votre compte est verrouillé."
|
||||
signed_up_but_unconfirmed: "Nous vous avons envoyé un email contenant un lien d'activation. Ouvrez ce lien pour activer votre compte."
|
||||
update_needs_confirmation: "Votre compte a bien été mis à jour mais nous devons vérifier votre nouvelle adresse email. Merci de vérifier vos email et de cliquer sur le lien d'activation pour finaliser la validation de votre nouvelle adresse."
|
||||
update_needs_confirmation: "Votre compte a bien été mis à jour mais nous devons vérifier votre nouvelle adresse email. Merci de vérifier vos emails et de cliquer sur le lien d’activation pour finaliser la validation de votre nouvelle adresse."
|
||||
updated: "Votre compte a été modifié avec succès."
|
||||
sessions:
|
||||
signed_in: "Connecté."
|
||||
|
|
|
@ -291,6 +291,12 @@ Rails.application.routes.draw do
|
|||
end
|
||||
resource :feedback, only: [:create]
|
||||
get 'demarches' => 'demarches#index'
|
||||
|
||||
get 'profil' => 'profil#show'
|
||||
post 'renew-api-token' => 'profil#renew_api_token'
|
||||
# allow refresh 'renew api token' page
|
||||
get 'renew-api-token' => redirect('/profil')
|
||||
patch 'update_email' => 'profil#update_email'
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -377,11 +383,6 @@ Rails.application.routes.draw do
|
|||
patch 'add_to_procedure'
|
||||
end
|
||||
end
|
||||
|
||||
get 'profil' => 'profil#show'
|
||||
post 'renew-api-token' => 'profil#renew_api_token'
|
||||
# allow refresh 'renew api token' page
|
||||
get 'renew-api-token' => redirect('/profil')
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddUnconfirmedEmailColumnToUsers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :users, :unconfirmed_email, :text
|
||||
end
|
||||
end
|
5
db/migrate/20190704144304_drop_administrateur_id.rb
Normal file
5
db/migrate/20190704144304_drop_administrateur_id.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class DropAdministrateurId < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
remove_reference :procedures, :administrateur
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2019_06_27_132911) do
|
||||
ActiveRecord::Schema.define(version: 2019_07_04_144304) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -474,7 +474,6 @@ ActiveRecord::Schema.define(version: 2019_06_27_132911) do
|
|||
t.string "lien_demarche"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "administrateur_id"
|
||||
t.boolean "euro_flag", default: false
|
||||
t.string "logo"
|
||||
t.boolean "cerfa_flag", default: false
|
||||
|
@ -606,6 +605,7 @@ ActiveRecord::Schema.define(version: 2019_06_27_132911) do
|
|||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at"
|
||||
t.datetime "confirmation_sent_at"
|
||||
t.text "unconfirmed_email"
|
||||
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||
t.index ["email"], name: "index_users_on_email", unique: true
|
||||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||
|
|
|
@ -105,16 +105,26 @@ describe Gestionnaires::DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
describe '#passer_en_instruction' do
|
||||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||
|
||||
before do
|
||||
dossier.en_construction!
|
||||
sign_in gestionnaire
|
||||
post :passer_en_instruction, params: { procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js'
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.state).to eq(Dossier.states.fetch(:en_instruction)) }
|
||||
it { expect(response.body).to include('.state-button') }
|
||||
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction)) }
|
||||
it { expect(gestionnaire.follow?(dossier)).to be true }
|
||||
it { expect(response).to have_http_status(:ok) }
|
||||
it { expect(response.body).to include('.state-button') }
|
||||
|
||||
context 'when the dossier has already been put en_instruction' do
|
||||
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
|
||||
|
||||
it 'warns about the error, but doesn’t raise' do
|
||||
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction))
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#repasser_en_construction' do
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe NewAdministrateur::ProfilController, type: :controller do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
|
||||
before { sign_in(administrateur) }
|
||||
|
||||
describe 'POST #renew_api_token' do
|
||||
before do
|
||||
allow(administrateur).to receive(:renew_api_token)
|
||||
allow(controller).to receive(:current_administrateur) { administrateur }
|
||||
post :renew_api_token
|
||||
end
|
||||
|
||||
it { expect(administrateur).to have_received(:renew_api_token) }
|
||||
it { expect(response.status).to render_template(:show) }
|
||||
it { expect(flash.notice).to eq('Votre jeton a été regénéré.') }
|
||||
end
|
||||
end
|
60
spec/controllers/users/profil_controller_spec.rb
Normal file
60
spec/controllers/users/profil_controller_spec.rb
Normal file
|
@ -0,0 +1,60 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Users::ProfilController, type: :controller do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'POST #renew_api_token' do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
|
||||
before { sign_in(administrateur) }
|
||||
|
||||
before do
|
||||
allow(administrateur).to receive(:renew_api_token)
|
||||
allow(controller).to receive(:current_administrateur) { administrateur }
|
||||
post :renew_api_token
|
||||
end
|
||||
|
||||
it { expect(administrateur).to have_received(:renew_api_token) }
|
||||
it { expect(response.status).to render_template(:show) }
|
||||
it { expect(flash.notice).to eq('Votre jeton a été regénéré.') }
|
||||
end
|
||||
|
||||
describe 'PATCH #update_email' do
|
||||
context 'when everything is fine' do
|
||||
before do
|
||||
patch :update_email, params: { user: { email: 'loulou@lou.com' } }
|
||||
user.reload
|
||||
end
|
||||
|
||||
it { expect(user.unconfirmed_email).to eq('loulou@lou.com') }
|
||||
it { expect(response).to redirect_to(profil_path) }
|
||||
it { expect(flash.notice).to eq(I18n.t('devise.registrations.update_needs_confirmation')) }
|
||||
end
|
||||
|
||||
context 'when the mail is already taken' do
|
||||
let!(:user2) { create(:user) }
|
||||
|
||||
before do
|
||||
patch :update_email, params: { user: { email: user2.email } }
|
||||
user.reload
|
||||
end
|
||||
|
||||
it { expect(response).to redirect_to(profil_path) }
|
||||
it { expect(flash.notice).to eq(I18n.t('devise.registrations.update_needs_confirmation')) }
|
||||
end
|
||||
|
||||
context 'when the mail is incorrect' do
|
||||
let!(:user2) { create(:user) }
|
||||
|
||||
before do
|
||||
patch :update_email, params: { user: { email: 'incorrect' } }
|
||||
user.reload
|
||||
end
|
||||
|
||||
it { expect(response).to redirect_to(profil_path) }
|
||||
it { expect(flash.alert).to eq(['Email invalide']) }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -4,7 +4,7 @@ FactoryBot.define do
|
|||
|
||||
before(:create) do |commentaire, _evaluator|
|
||||
if !commentaire.dossier
|
||||
commentaire.dossier = create :dossier
|
||||
commentaire.dossier = create :dossier, :en_construction
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,7 @@ feature 'Administrator connection' do
|
|||
let(:email) { 'admin1@admin.com' }
|
||||
let(:password) { 'mon chien aime les bananes' }
|
||||
let!(:admin) { create(:administrateur, :with_procedure, email: email, password: password) }
|
||||
let!(:user) { create(:user, email: email, password: password) }
|
||||
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:enable_email_login_token, true)
|
||||
|
|
32
spec/features/users/change_email_spec.rb
Normal file
32
spec/features/users/change_email_spec.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'Changing an email' do
|
||||
let(:old_email) { 'old@email.com' }
|
||||
let(:user) { create(:user, email: old_email) }
|
||||
|
||||
before do
|
||||
login_as user, scope: :user
|
||||
end
|
||||
|
||||
scenario 'is easy' do
|
||||
new_email = 'new@email.com'
|
||||
|
||||
visit '/profil'
|
||||
|
||||
fill_in :user_email, with: new_email
|
||||
|
||||
perform_enqueued_jobs do
|
||||
click_button 'Changer mon adresse'
|
||||
end
|
||||
|
||||
user.reload
|
||||
expect(user.email).to eq(old_email)
|
||||
expect(user.unconfirmed_email).to eq(new_email)
|
||||
|
||||
click_confirmation_link_for(new_email)
|
||||
|
||||
user.reload
|
||||
expect(user.email).to eq(new_email)
|
||||
expect(user.unconfirmed_email).to be_nil
|
||||
end
|
||||
end
|
|
@ -32,7 +32,7 @@ RSpec.describe CommentaireHelper, type: :helper do
|
|||
end
|
||||
|
||||
describe '.commentaire_is_from_guest' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:dossier) { create(:dossier, :en_instruction) }
|
||||
let!(:guest) { create(:invite, dossier: dossier) }
|
||||
|
||||
subject { commentaire_is_from_guest(commentaire) }
|
||||
|
|
|
@ -7,12 +7,66 @@ describe Commentaire do
|
|||
it { is_expected.to have_db_column(:updated_at) }
|
||||
it { is_expected.to belong_to(:dossier) }
|
||||
|
||||
describe 'messagerie_available validation' do
|
||||
subject { commentaire.valid?(:create) }
|
||||
|
||||
context 'with a commentaire created by the DS system' do
|
||||
let(:commentaire) { build :commentaire, email: CONTACT_EMAIL }
|
||||
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context 'on an archived dossier' do
|
||||
let(:dossier) { create :dossier, :archived }
|
||||
let(:commentaire) { build :commentaire, dossier: dossier }
|
||||
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
|
||||
context 'on a dossier en_construction' do
|
||||
let(:dossier) { create :dossier, :en_construction }
|
||||
let(:commentaire) { build :commentaire, dossier: dossier }
|
||||
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#sent_by_system?" do
|
||||
subject { commentaire.sent_by_system? }
|
||||
|
||||
let(:commentaire) { build :commentaire, email: email }
|
||||
|
||||
context 'with a commentaire created by the DS system' do
|
||||
let(:email) { CONTACT_EMAIL }
|
||||
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#redacted_email" do
|
||||
subject { commentaire.redacted_email }
|
||||
|
||||
context 'with a commentaire created by a gestionnaire' do
|
||||
let(:commentaire) { build :commentaire, gestionnaire: gestionnaire }
|
||||
let(:gestionnaire) { build :gestionnaire, email: 'some_user@exemple.fr' }
|
||||
|
||||
it { is_expected.to eq 'some_user' }
|
||||
end
|
||||
|
||||
context 'with a commentaire created by a user' do
|
||||
let(:commentaire) { build :commentaire, user: user }
|
||||
let(:user) { build :user, email: 'some_user@exemple.fr' }
|
||||
|
||||
it { is_expected.to eq 'some_user@exemple.fr' }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#notify" do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
let(:assign_to) { create(:assign_to, gestionnaire: gestionnaire, procedure: procedure) }
|
||||
let(:user) { create(:user) }
|
||||
let(:dossier) { create(:dossier, procedure: procedure, user: user) }
|
||||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure, user: user) }
|
||||
let(:commentaire) { Commentaire.new(dossier: dossier, body: "Mon commentaire") }
|
||||
|
||||
context "with a commentaire created by a gestionnaire" do
|
||||
|
|
|
@ -107,6 +107,7 @@ describe User, type: :model do
|
|||
gestionnaire = create(:gestionnaire, email: user.email)
|
||||
|
||||
user.update(email: 'whoami@plop.com', password: 'super secret')
|
||||
user.confirm
|
||||
|
||||
gestionnaire.reload
|
||||
expect(gestionnaire.email).to eq('whoami@plop.com')
|
||||
|
@ -118,6 +119,7 @@ describe User, type: :model do
|
|||
admin = create(:administrateur, email: user.email)
|
||||
|
||||
user.update(email: 'whoami@plop.com', password: 'super secret')
|
||||
user.confirm
|
||||
|
||||
admin.reload
|
||||
expect(admin.email).to eq('whoami@plop.com')
|
||||
|
|
|
@ -113,8 +113,8 @@ describe AdministrateurUsageStatisticsService do
|
|||
nb_dossiers_max: 21,
|
||||
nb_dossiers_traite: 7,
|
||||
nb_dossiers_dossier_en_instruction: 7,
|
||||
admin_roi_low: 147.84,
|
||||
admin_roi_high: 362.25
|
||||
admin_roi_low: 147,
|
||||
admin_roi_high: 357
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -192,8 +192,8 @@ describe AdministrateurUsageStatisticsService do
|
|||
nb_dossiers_max: 3,
|
||||
nb_dossiers_traite: 1,
|
||||
nb_dossiers_dossier_en_instruction: 1,
|
||||
admin_roi_low: 21.12,
|
||||
admin_roi_high: 51.75
|
||||
admin_roi_low: 21,
|
||||
admin_roi_high: 51
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -222,8 +222,8 @@ describe AdministrateurUsageStatisticsService do
|
|||
nb_dossiers_max: 21,
|
||||
nb_dossiers_traite: 7,
|
||||
nb_dossiers_dossier_en_instruction: 7,
|
||||
admin_roi_low: 147.84,
|
||||
admin_roi_high: 362.25
|
||||
admin_roi_low: 147,
|
||||
admin_roi_high: 357
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -80,6 +80,13 @@ describe ProcedureExportV2Service do
|
|||
it 'should have data' do
|
||||
expect(dossiers_sheet.data.size).to eq(1)
|
||||
expect(etablissements_sheet.data.size).to eq(1)
|
||||
|
||||
# SimpleXlsxReader is transforming datetimes in utc... It is only used in test so we just hack around.
|
||||
offset = dossier.en_construction_at.utc_offset
|
||||
en_construction_at = Time.zone.at(dossiers_sheet.data[0][9] - offset.seconds)
|
||||
en_instruction_at = Time.zone.at(dossiers_sheet.data[0][10] - offset.seconds)
|
||||
expect(en_construction_at).to eq(dossier.en_construction_at.round)
|
||||
expect(en_instruction_at).to eq(dossier.en_instruction_at.round)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ describe 'shared/dossiers/messages/message.html.haml', type: :view do
|
|||
|
||||
subject { render 'shared/dossiers/messages/message.html.haml', commentaire: commentaire, messagerie_seen_at: seen_at, connected_user: dossier.user }
|
||||
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:dossier) { create(:dossier, :en_construction) }
|
||||
let(:commentaire) { create(:commentaire, dossier: dossier) }
|
||||
let(:seen_at) { commentaire.created_at + 1.hour }
|
||||
|
||||
|
|
Loading…
Reference in a new issue