diff --git a/app/lib/pipedrive/person_adapter.rb b/app/lib/pipedrive/person_adapter.rb
index 88d6526fd..a6289bb90 100644
--- a/app/lib/pipedrive/person_adapter.rb
+++ b/app/lib/pipedrive/person_adapter.rb
@@ -10,6 +10,7 @@ class Pipedrive::PersonAdapter
nom: datum['name'],
poste: datum[PIPEDRIVE_POSTE_ATTRIBUTE_ID],
email: datum.dig('email', 0, 'value'),
+ tel: datum.dig('phone', 0, 'value'),
organisation: datum['org_name']
}
end
diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb
index 589cc7f27..dab20d0ac 100644
--- a/app/models/gestionnaire.rb
+++ b/app/models/gestionnaire.rb
@@ -140,8 +140,8 @@ class Gestionnaire < ApplicationRecord
end
def login_token_valid?(login_token)
- BCrypt::Password.new(encrypted_login_token) == login_token
- 30.minutes.ago < login_token_created_at
+ BCrypt::Password.new(encrypted_login_token) == login_token &&
+ 30.minutes.ago < login_token_created_at
rescue BCrypt::Errors::InvalidHash
false
end
diff --git a/app/views/administration_mailer/dossier_expiration_summary.html.haml b/app/views/administration_mailer/dossier_expiration_summary.html.haml
index dc9488ca3..6a15b618c 100644
--- a/app/views/administration_mailer/dossier_expiration_summary.html.haml
+++ b/app/views/administration_mailer/dossier_expiration_summary.html.haml
@@ -1,7 +1,7 @@
- content_for(:title, 'Expiration du délai de conservation des dossiers')
- if @expired_dossiers.present?
- %h1= t('mail.administration.dossier_expiration_summary.expired_dossiers', count: @expired_dossiers.count)
+ %h2= t('mail.administration.dossier_expiration_summary.expired_dossiers', count: @expired_dossiers.count)
- @expired_dossiers.group_by(&:procedure).each do |procedure, dossiers|
%dl
%dt
@@ -10,7 +10,7 @@
= dossiers.map { |d| link_to(d.id, manager_dossier_url(d)) }.join(', ').html_safe
- if @expiring_dossiers.present?
- %h1= t('mail.administration.dossier_expiration_summary.expiring_dossiers', count: @expiring_dossiers.count)
+ %h2= t('mail.administration.dossier_expiration_summary.expiring_dossiers', count: @expiring_dossiers.count)
- @expiring_dossiers.group_by(&:procedure).each do |procedure, dossiers|
%dl
%dt
diff --git a/app/views/avis_mailer/avis_invitation.html.haml b/app/views/avis_mailer/avis_invitation.html.haml
index bf39822b7..860e0d256 100644
--- a/app/views/avis_mailer/avis_invitation.html.haml
+++ b/app/views/avis_mailer/avis_invitation.html.haml
@@ -1,5 +1,4 @@
-- content_for(:title, 'Vous avez été invité à donner votre avis')
-
+- content_for(:title, 'Invitation à donner votre avis')
- avis_link = @avis.gestionnaire.present? ? gestionnaire_avis_url(@avis) : sign_up_gestionnaire_avis_url(@avis.id, @avis.email)
- content_for(:footer) do
@@ -21,7 +20,7 @@
%p
= "#{@avis.claimant.email} vous a écrit :"
%br
-%p{ style: "padding: 8px; color: #333333; background-color: #EEEEEE; font-size: 16px;" }
+%p{ style: "padding: 8px; color: #333333; background-color: #EEEEEE; font-size: 14px;" }
= @avis.introduction
- if @avis.gestionnaire.present?
diff --git a/app/views/gestionnaire_mailer/last_week_overview.html.haml b/app/views/gestionnaire_mailer/last_week_overview.html.haml
index 6486b6807..43b2950ae 100644
--- a/app/views/gestionnaire_mailer/last_week_overview.html.haml
+++ b/app/views/gestionnaire_mailer/last_week_overview.html.haml
@@ -1,8 +1,14 @@
- content_for(:title, @subject)
+%p
+ Bonjour,
+
+%p
+ Voici le résumé de votre activité hebdomadaire :
+
- @overview[:procedure_overviews].each_with_index do |procedure_overview, index|
- %h2{ style: 'font-size: 20px; font-weight: 300; margin: 25px 0 5px;' }
+ %h2{ style: 'font-size: 16px; font-weight: 300; margin: 25px 0 5px;' }
#{procedure_overview.procedure.libelle}
= link_to 'voir', gestionnaire_procedure_url(procedure_overview.procedure), style: 'color: #0069CC; font-size: 14px;'
%table{ cellpadding: '0', cellspacing: '0', style: 'width: 100%; padding-bottom: 20px;' }
diff --git a/app/views/invite_mailer/invite_guest.html.haml b/app/views/invite_mailer/invite_guest.html.haml
index 27fe008dd..2b30029d2 100644
--- a/app/views/invite_mailer/invite_guest.html.haml
+++ b/app/views/invite_mailer/invite_guest.html.haml
@@ -4,7 +4,9 @@
%p
L'utilisateur
= @invite.email_sender
- souhaite que vous participiez à l'élaboration d'un dossier sur demarches-simplifiees.fr.
+ souhaite que vous participiez à l'élaboration d'un dossier pour la démarche
+ %strong= @invite.dossier.procedure.libelle
+ sur demarches-simplifiees.fr.
%p
Cette plateforme permet à ses utilisateurs d'établir des dossiers 100 % en ligne et de dialoguer avec plusieurs interlocuteurs privilégiés avant d'instruire un dépot.
diff --git a/app/views/layouts/_navbar.html.haml b/app/views/layouts/_navbar.html.haml
index 558e981e8..79448dc56 100644
--- a/app/views/layouts/_navbar.html.haml
+++ b/app/views/layouts/_navbar.html.haml
@@ -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 ? #{CONTACT_PHONE} ou #{CONTACT_EMAIL}
+ Besoin d'aide ? #{CONTACT_PHONE} ou par email
-# BEST WTF EVER
-# this begin rescue hides potentials bugs by displaying another navbar
- begin
diff --git a/app/views/manager/demandes/index.html.erb b/app/views/manager/demandes/index.html.erb
index 7a45aa726..9703d5fdb 100644
--- a/app/views/manager/demandes/index.html.erb
+++ b/app/views/manager/demandes/index.html.erb
@@ -34,13 +34,14 @@
<%= form_tag(manager_demandes_create_administrateur_path) do -%>
<%= select_tag "stage_id",
options_for_select({
+ "suspect" => Pipedrive::DealAdapter::PIPEDRIVE_SUSPECTS_COMPTE_CREE_STAGE_ID,
"administration centrale" => Pipedrive::DealAdapter::PIPEDRIVE_ADMIN_CENTRAL_STOCK_STAGE_ID,
"service déco. régional" => Pipedrive::DealAdapter::PIPEDRIVE_SERVICE_DECO_REGIONAL_STOCK_STAGE_ID,
"service déco. départemental" => Pipedrive::DealAdapter::PIPEDRIVE_SERVICE_DECO_DEPARTEMENTAL_STOCK_STAGE_ID,
"collectivité dép. ou rég." =>Pipedrive::DealAdapter::PIPEDRIVE_COLLECTIVITE_DEP_OU_REG_STOCK_STAGE_ID,
"collectivité locale" => Pipedrive::DealAdapter::PIPEDRIVE_COLLECTIVITE_LOCALE_STOCK_STAGE_ID,
- "organisme" => Pipedrive::DealAdapter::PIPEDRIVE_ORGANISMES_STOCK_STAGE_ID,
- "suspect" => Pipedrive::DealAdapter::PIPEDRIVE_SUSPECTS_COMPTE_CREE_STAGE_ID
+ "organisme" => Pipedrive::DealAdapter::PIPEDRIVE_ORGANISMES_STOCK_STAGE_ID
+
}),
style: 'margin-bottom: 20px; width: inherit;' %>
diff --git a/spec/controllers/users/sessions_controller_spec.rb b/spec/controllers/users/sessions_controller_spec.rb
index b6601b4b9..d34e3f280 100644
--- a/spec/controllers/users/sessions_controller_spec.rb
+++ b/spec/controllers/users/sessions_controller_spec.rb
@@ -255,11 +255,11 @@ describe Users::SessionsController, type: :controller do
let(:gestionnaire) { create(:gestionnaire) }
before do
allow(controller).to receive(:trust_device)
- post :sign_in_by_link, params: { id: gestionnaire.id, login_token: login_token }
+ post :sign_in_by_link, params: { id: gestionnaire.id, jeton: jeton }
end
context 'when the token is valid' do
- let(:login_token) { gestionnaire.login_token! }
+ let(:jeton) { gestionnaire.login_token! }
# TODO when the gestionnaire has no other account, and the token is valid, and the user signing in was not starting a demarche,
# redirect to root_path, then redirect to gestionnaire_procedures_path (see root_controller)
@@ -269,7 +269,7 @@ describe Users::SessionsController, type: :controller do
end
context 'when the token is invalid' do
- let(:login_token) { 'invalid_token' }
+ let(:jeton) { 'invalid_token' }
it { is_expected.to redirect_to new_user_session_path }
it { expect(controller.current_gestionnaire).to be_nil }
@@ -286,11 +286,11 @@ describe Users::SessionsController, type: :controller do
let!(:administrateur) { create(:administrateur, email: email, password: password) }
before do
- post :sign_in_by_link, params: { id: gestionnaire.id, login_token: login_token }
+ post :sign_in_by_link, params: { id: gestionnaire.id, jeton: jeton }
end
context 'when the token is valid' do
- let(:login_token) { gestionnaire.login_token! }
+ let(:jeton) { gestionnaire.login_token! }
it { expect(controller.current_gestionnaire).to eq(gestionnaire) }
it { expect(controller.current_administrateur).to eq(administrateur) }
diff --git a/spec/mailers/previews/administrateur_mailer_preview.rb b/spec/mailers/previews/administrateur_mailer_preview.rb
index 67e6a54b9..afa8762a0 100644
--- a/spec/mailers/previews/administrateur_mailer_preview.rb
+++ b/spec/mailers/previews/administrateur_mailer_preview.rb
@@ -1,5 +1,7 @@
class AdministrateurMailerPreview < ActionMailer::Preview
def activate_before_expiration
- AdministrateurMailer.activate_before_expiration(Administrateur.inactive.where.not(reset_password_token: nil).last)
+ administrateur = Administrateur.new(reset_password_sent_at: Time.now.utc)
+
+ AdministrateurMailer.activate_before_expiration(administrateur, "a4d4e4f4b4d445")
end
end
diff --git a/spec/mailers/previews/administration_mailer_preview.rb b/spec/mailers/previews/administration_mailer_preview.rb
index 7e5633c31..0aaa8a069 100644
--- a/spec/mailers/previews/administration_mailer_preview.rb
+++ b/spec/mailers/previews/administration_mailer_preview.rb
@@ -1,17 +1,42 @@
class AdministrationMailerPreview < ActionMailer::Preview
def dubious_procedures
procedures_and_champs = [
- [Procedure.first, [TypeDeChamp.new(libelle: 'iban'), TypeDeChamp.new(libelle: 'religion')]],
- [Procedure.last, [TypeDeChamp.new(libelle: 'iban'), TypeDeChamp.new(libelle: 'numéro de carte bleu')]]
+ [procedure_1, [TypeDeChamp.new(libelle: 'iban'), TypeDeChamp.new(libelle: 'religion')]],
+ [procedure_2, [TypeDeChamp.new(libelle: 'iban'), TypeDeChamp.new(libelle: 'numéro de carte bleu')]]
]
AdministrationMailer.dubious_procedures(procedures_and_champs)
end
def invite_admin
- AdministrationMailer.invite_admin(Administrateur.last, "12345678", 0)
+ AdministrationMailer.invite_admin(administrateur, "12345678", 0)
end
def refuse_admin
AdministrationMailer.refuse_admin('bad_admin@pipo.com')
end
+
+ def new_admin
+ administration = Administration.new(email: 'superadmin@demarches-simplifiees.fr')
+ AdministrationMailer.new_admin_email(administrateur, administration)
+ end
+
+ def dossier_expiration_summary
+ expiring_dossiers = [Dossier.new(id: 100, procedure: procedure_1)]
+ expired_dossiers = [Dossier.new(id: 100, procedure: procedure_2)]
+ AdministrationMailer.dossier_expiration_summary(expiring_dossiers, expired_dossiers)
+ end
+
+ private
+
+ def procedure_1
+ Procedure.new(id: 10, libelle: "Démarche des marches", administrateur: administrateur)
+ end
+
+ def procedure_2
+ Procedure.new(id: 20, libelle: "Démarche pieds", administrateur: administrateur)
+ end
+
+ def administrateur
+ Administrateur.new(id: 111, email: "chef.de.service@administration.gouv.fr")
+ end
end
diff --git a/spec/mailers/previews/avis_mailer_preview.rb b/spec/mailers/previews/avis_mailer_preview.rb
index be78eae74..72d715f93 100644
--- a/spec/mailers/previews/avis_mailer_preview.rb
+++ b/spec/mailers/previews/avis_mailer_preview.rb
@@ -1,6 +1,11 @@
# Preview all emails at http://localhost:3000/rails/mailers/avis_mailer
class AvisMailerPreview < ActionMailer::Preview
def avis_invitation
- AvisMailer.avis_invitation(Avis.last)
+ gestionaire = Gestionnaire.new(id: 1, email: 'jeanmichel.de-chauvigny@exemple.fr')
+ avis = Avis.new(id: 1, email: 'test@exemple.fr', claimant: gestionaire)
+ avis.dossier = Dossier.new(id: 1)
+ avis.dossier.procedure = Procedure.new(libelle: 'Démarche pour faire des marches')
+ avis.introduction = 'Il faudrait vérifier le certificat de conformité.'
+ AvisMailer.avis_invitation(avis)
end
end
diff --git a/spec/mailers/previews/devise_user_mailer_preview.rb b/spec/mailers/previews/devise_user_mailer_preview.rb
index fdaab876b..6aea003ec 100644
--- a/spec/mailers/previews/devise_user_mailer_preview.rb
+++ b/spec/mailers/previews/devise_user_mailer_preview.rb
@@ -1,9 +1,15 @@
class DeviseUserMailerPreview < ActionMailer::Preview
def confirmation_instructions
- DeviseUserMailer.confirmation_instructions(User.first, "faketoken", {})
+ DeviseUserMailer.confirmation_instructions(user, "faketoken", {})
end
def reset_password_instructions
- DeviseUserMailer.reset_password_instructions(User.first, "faketoken", {})
+ DeviseUserMailer.reset_password_instructions(user, "faketoken", {})
+ end
+
+ private
+
+ def user
+ User.new(id: 10, email: "usager@example.com")
end
end
diff --git a/spec/mailers/previews/dossier_mailer_preview.rb b/spec/mailers/previews/dossier_mailer_preview.rb
index de22920f6..b914b27c5 100644
--- a/spec/mailers/previews/dossier_mailer_preview.rb
+++ b/spec/mailers/previews/dossier_mailer_preview.rb
@@ -1,18 +1,32 @@
# Preview all emails at http://localhost:3000/rails/mailers/dossier_mailer
class DossierMailerPreview < ActionMailer::Preview
def notify_new_draft
- DossierMailer.notify_new_draft(Dossier.last)
+ DossierMailer.notify_new_draft(dossier)
end
def notify_new_answer
- DossierMailer.notify_new_answer(Dossier.last)
+ DossierMailer.notify_new_answer(dossier)
end
def notify_deletion_to_user
- DossierMailer.notify_deletion_to_user(DeletedDossier.last, "user@ds.fr")
+ DossierMailer.notify_deletion_to_user(deleted_dossier, "user@ds.fr")
end
def notify_deletion_to_administration
- DossierMailer.notify_deletion_to_administration(DeletedDossier.last, "admin@ds.fr")
+ DossierMailer.notify_deletion_to_administration(deleted_dossier, "admin@ds.fr")
+ end
+
+ private
+
+ def deleted_dossier
+ DeletedDossier.new(dossier_id: 1, procedure: procedure)
+ end
+
+ def dossier
+ Dossier.new(id: 1, procedure: procedure, user: User.new(email: "usager@example.com"))
+ end
+
+ def procedure
+ Procedure.new(libelle: 'Démarche pour des marches')
end
end
diff --git a/spec/mailers/previews/gestionnaire_mailer_preview.rb b/spec/mailers/previews/gestionnaire_mailer_preview.rb
index d7707bd22..ddafd66b4 100644
--- a/spec/mailers/previews/gestionnaire_mailer_preview.rb
+++ b/spec/mailers/previews/gestionnaire_mailer_preview.rb
@@ -1,14 +1,35 @@
class GestionnaireMailerPreview < ActionMailer::Preview
def last_week_overview
- gestionnaire = Gestionnaire.first
- GestionnaireMailer.last_week_overview(gestionnaire)
+ GestionnaireMailer.last_week_overview(Gestionnaire.first)
end
def send_dossier
- GestionnaireMailer.send_dossier(Gestionnaire.first, Dossier.first, Gestionnaire.last)
+ GestionnaireMailer.send_dossier(gestionnaire, Dossier.new(id: 10, procedure: procedure), target_gestionnaire)
end
def send_login_token
- GestionnaireMailer.send_login_token(Gestionnaire.first, "token")
+ GestionnaireMailer.send_login_token(gestionnaire, "token")
+ end
+
+ def invite_gestionnaire
+ GestionnaireMailer.invite_gestionnaire(gestionnaire, 'aedfa0d0')
+ end
+
+ def user_to_gestionnaire
+ GestionnaireMailer.user_to_gestionnaire(gestionnaire.email)
+ end
+
+ private
+
+ def gestionnaire
+ Gestionnaire.new(id: 10, email: 'instructeur@administration.gouv.fr')
+ end
+
+ def target_gestionnaire
+ Gestionnaire.new(id: 12, email: 'collegue@administration.gouv.fr')
+ end
+
+ def procedure
+ Procedure.new(id: 15)
end
end
diff --git a/spec/mailers/previews/user_mailer_preview.rb b/spec/mailers/previews/user_mailer_preview.rb
index d2dfa3e70..4204d63be 100644
--- a/spec/mailers/previews/user_mailer_preview.rb
+++ b/spec/mailers/previews/user_mailer_preview.rb
@@ -1,5 +1,11 @@
class UserMailerPreview < ActionMailer::Preview
def new_account_warning
- UserMailer.new_account_warning(User.first)
+ UserMailer.new_account_warning(user)
+ end
+
+ private
+
+ def user
+ User.new(id: 10, email: 'test@exemple.fr')
end
end
diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb
index f0d0f6447..3db3a5c56 100644
--- a/spec/support/feature_helpers.rb
+++ b/spec/support/feature_helpers.rb
@@ -27,10 +27,11 @@ module FeatureHelpers
if sign_in_by_link
mail = ActionMailer::Base.deliveries.last
- message = mail.body.parts.join(&:to_s)
- login_token = message[/connexion-par-jeton\/(.*)/, 1]
+ message = mail.html_part.body.raw_source
+ gestionnaire_id = message[/\".+\/connexion-par-jeton\/(.+)\?jeton=(.*)\"/, 1]
+ jeton = message[/\".+\/connexion-par-jeton\/(.+)\?jeton=(.*)\"/, 2]
- visit sign_in_by_link_path(login_token)
+ visit sign_in_by_link_path(gestionnaire_id, jeton: jeton)
end
end