commit
a6f274f790
41 changed files with 184 additions and 125 deletions
|
@ -30,4 +30,10 @@
|
|||
a {
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.monavis {
|
||||
img {
|
||||
margin-top: 2 * $default-padding;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,21 @@ module Manager
|
|||
head :ok
|
||||
end
|
||||
|
||||
def delete
|
||||
administrateur = Administrateur.find(params[:id])
|
||||
|
||||
if !administrateur.can_be_deleted?
|
||||
fail "Impossible de supprimer cet administrateur car il a des dossiers ou des procédures"
|
||||
end
|
||||
administrateur.dossiers.each(&:delete_and_keep_track)
|
||||
administrateur.destroy
|
||||
|
||||
logger.info("L'administrateur #{administrateur.id} est supprimé par #{current_user.id}")
|
||||
flash[:notice] = "L'administrateur #{administrateur.id} est supprimé"
|
||||
|
||||
redirect_to manager_administrateurs_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_administrateur_params
|
||||
|
|
|
@ -8,8 +8,9 @@ module NewAdministrateur
|
|||
@service = procedure.service
|
||||
|
||||
mail_template = find_mail_template_by_slug(params[:id])
|
||||
@rendered_template = sanitize(mail_template.body)
|
||||
|
||||
render(html: sanitize(mail_template.body), layout: 'mailers/notification')
|
||||
render(template: 'notification_mailer/send_notification', layout: 'mailers/notifications_layout')
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -13,7 +13,7 @@ class DossierMailer < ApplicationMailer
|
|||
subject = "Retrouvez votre brouillon pour la démarche « #{dossier.procedure.libelle} »"
|
||||
|
||||
mail(to: dossier.user.email, subject: subject) do |format|
|
||||
format.html { render layout: 'mailers/notification' }
|
||||
format.html { render layout: 'mailers/notifications_layout' }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -25,7 +25,7 @@ class DossierMailer < ApplicationMailer
|
|||
subject = "Nouveau message pour votre dossier nº #{dossier.id} (#{dossier.procedure.libelle})"
|
||||
|
||||
mail(to: dossier.user.email, subject: subject) do |format|
|
||||
format.html { render layout: 'mailers/notification' }
|
||||
format.html { render layout: 'mailers/notifications_layout' }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,8 +6,12 @@
|
|||
# The subject and body of a Notification can be customized by each demarche.
|
||||
#
|
||||
class NotificationMailer < ApplicationMailer
|
||||
include ActionView::Helpers::SanitizeHelper
|
||||
|
||||
helper ServiceHelper
|
||||
|
||||
layout 'mailers/notifications_layout'
|
||||
|
||||
def send_dossier_received(dossier)
|
||||
send_notification(dossier, dossier.procedure.received_mail_template)
|
||||
end
|
||||
|
@ -41,12 +45,9 @@ class NotificationMailer < ApplicationMailer
|
|||
@dossier = dossier
|
||||
@service = dossier.procedure.service
|
||||
@logo_url = attach_logo(dossier.procedure)
|
||||
@rendered_template = sanitize(body)
|
||||
|
||||
mail(subject: subject, to: email) do |format|
|
||||
# rubocop:disable Rails/OutputSafety
|
||||
format.html { render(html: body.html_safe, layout: 'mailers/notification') }
|
||||
# rubocop:enable Rails/OutputSafety
|
||||
end
|
||||
mail(subject: subject, to: email, template_name: 'send_notification')
|
||||
end
|
||||
|
||||
def create_commentaire_for_notification(dossier, subject, body)
|
||||
|
|
|
@ -123,4 +123,8 @@ class Administrateur < ApplicationRecord
|
|||
def gestionnaire
|
||||
Gestionnaire.find_by(email: email)
|
||||
end
|
||||
|
||||
def can_be_deleted?
|
||||
dossiers.state_instruction_commencee.none? && procedures.none?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,6 +15,8 @@ class Dossier < ApplicationRecord
|
|||
INSTRUCTION_COMMENCEE = TERMINE + [states.fetch(:en_instruction)]
|
||||
SOUMIS = EN_CONSTRUCTION_OU_INSTRUCTION + TERMINE
|
||||
|
||||
TAILLE_MAX_ZIP = 50.megabytes
|
||||
|
||||
has_one :etablissement, dependent: :destroy
|
||||
has_one :individual, dependent: :destroy
|
||||
has_one :attestation, dependent: :destroy
|
||||
|
@ -461,7 +463,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def attachments_downloadable?
|
||||
!PiecesJustificativesService.liste_pieces_justificatives(self).empty? && PiecesJustificativesService.pieces_justificatives_total_size(self) < 50.megabytes
|
||||
!PiecesJustificativesService.liste_pieces_justificatives(self).empty? && PiecesJustificativesService.pieces_justificatives_total_size(self) < Dossier::TAILLE_MAX_ZIP
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -12,9 +12,9 @@ module Mails
|
|||
def self.default_template_name_for_procedure(procedure)
|
||||
attestation_template = procedure.attestation_template
|
||||
if attestation_template&.activated?
|
||||
"notification_mailer/closed_mail_with_attestation"
|
||||
"notification_mailer/default_templates/closed_mail_with_attestation"
|
||||
else
|
||||
"notification_mailer/closed_mail"
|
||||
"notification_mailer/default_templates/closed_mail"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ module Mails
|
|||
belongs_to :procedure
|
||||
|
||||
SLUG = "initiated_mail"
|
||||
DEFAULT_TEMPLATE_NAME = "notification_mailer/initiated_mail"
|
||||
DEFAULT_TEMPLATE_NAME = "notification_mailer/default_templates/initiated_mail"
|
||||
DISPLAYED_NAME = 'Accusé de réception'
|
||||
DEFAULT_SUBJECT = 'Votre dossier nº --numéro du dossier-- a bien été reçu (--libellé démarche--)'
|
||||
DOSSIER_STATE = Dossier.states.fetch(:en_construction)
|
||||
|
|
|
@ -5,7 +5,7 @@ module Mails
|
|||
belongs_to :procedure
|
||||
|
||||
SLUG = "received_mail"
|
||||
DEFAULT_TEMPLATE_NAME = "notification_mailer/received_mail"
|
||||
DEFAULT_TEMPLATE_NAME = "notification_mailer/default_templates/received_mail"
|
||||
DISPLAYED_NAME = 'Accusé de passage en instruction'
|
||||
DEFAULT_SUBJECT = 'Votre dossier nº --numéro du dossier-- va être instruit (--libellé démarche--)'
|
||||
DOSSIER_STATE = Dossier.states.fetch(:en_instruction)
|
||||
|
|
|
@ -5,7 +5,7 @@ module Mails
|
|||
belongs_to :procedure
|
||||
|
||||
SLUG = "refused_mail"
|
||||
DEFAULT_TEMPLATE_NAME = "notification_mailer/refused_mail"
|
||||
DEFAULT_TEMPLATE_NAME = "notification_mailer/default_templates/refused_mail"
|
||||
DISPLAYED_NAME = 'Accusé de rejet du dossier'
|
||||
DEFAULT_SUBJECT = 'Votre dossier nº --numéro du dossier-- a été refusé (--libellé démarche--)'
|
||||
DOSSIER_STATE = Dossier.states.fetch(:refuse)
|
||||
|
|
|
@ -5,7 +5,7 @@ module Mails
|
|||
belongs_to :procedure
|
||||
|
||||
SLUG = "without_continuation"
|
||||
DEFAULT_TEMPLATE_NAME = "notification_mailer/without_continuation_mail"
|
||||
DEFAULT_TEMPLATE_NAME = "notification_mailer/default_templates/without_continuation_mail"
|
||||
DISPLAYED_NAME = 'Accusé de classement sans suite'
|
||||
DEFAULT_SUBJECT = 'Votre dossier nº --numéro du dossier-- a été classé sans suite (--libellé démarche--)'
|
||||
DOSSIER_STATE = Dossier.states.fetch(:sans_suite)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.row.white-back
|
||||
#procedure_new.section.section-label
|
||||
= form_for @procedure, url: url_for({ controller: 'admin/procedures', action: :update_monavis, id: @procedure.id }), multipart: true do |f|
|
||||
= form_for @procedure, url: url_for({ controller: 'admin/procedures', action: :update_monavis }), multipart: true do |f|
|
||||
= render partial: 'monavis', locals: { f: f }
|
||||
.text-right
|
||||
= f.button 'Enregistrer', class: 'btn btn-success'
|
||||
|
|
|
@ -10,11 +10,6 @@
|
|||
%br
|
||||
Besoin d'aide ?
|
||||
%br
|
||||
> Nous proposons des ateliers en ligne pour vous aider à créer votre 1er formulaire et répondre à vos questions :
|
||||
= link_to "inscrivez-vous ici",
|
||||
"https://vimeo.com/334463514",
|
||||
target: "_blank"
|
||||
%br
|
||||
> Vous pouvez
|
||||
= link_to "visionner cette vidéo",
|
||||
"https://vimeo.com/261478872",
|
||||
|
@ -31,6 +26,11 @@
|
|||
"https://calendly.com/demarches-simplifiees/accompagnement-administrateur-demarches-simplifiees-fr",
|
||||
target: "_blank"
|
||||
|
||||
:javascript
|
||||
document.addEventListener("turbolinks:load", function() {
|
||||
$crisp.push(["do", "trigger:run", ["admin-signup"]]);
|
||||
});
|
||||
|
||||
|
||||
.form
|
||||
.send-wrapper
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
- content_for :procedure_logo do
|
||||
= render 'layouts/mailers/logo', url: @logo_url
|
||||
|
||||
%p
|
||||
Bonjour,
|
||||
|
||||
|
@ -10,4 +13,7 @@
|
|||
|
||||
= round_button('Lire le message', messagerie_dossier_url(@dossier))
|
||||
|
||||
= render partial: "layouts/mailers/signature", locals: { service: @service }
|
||||
= render 'layouts/mailers/signature', service: @service
|
||||
|
||||
- content_for :footer do
|
||||
= render 'layouts/mailers/service_footer', service: @service, dossier: @dossier
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
- content_for :procedure_logo do
|
||||
= render 'layouts/mailers/logo', url: @logo_url
|
||||
|
||||
%p
|
||||
Bonjour,
|
||||
|
||||
|
@ -10,4 +13,7 @@
|
|||
à l’adresse suivante :
|
||||
= link_to dossier_url(@dossier), dossier_url(@dossier), target: '_blank', rel: 'noopener'
|
||||
|
||||
= render partial: "layouts/mailers/signature"
|
||||
= render 'layouts/mailers/signature'
|
||||
|
||||
- content_for :footer do
|
||||
= render 'layouts/mailers/service_footer', service: @service, dossier: @dossier
|
||||
|
|
|
@ -18,13 +18,16 @@
|
|||
= link_to "Tout le dossier", print_gestionnaire_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link"
|
||||
%li
|
||||
= link_to "Uniquement cet onglet", "#", onclick: "window.print()", class: "menu-item menu-link"
|
||||
- if Flipflop.download_as_zip_enabled? && dossier.attachments_downloadable?
|
||||
- if Flipflop.download_as_zip_enabled? && !PiecesJustificativesService.liste_pieces_justificatives(dossier).empty?
|
||||
%span.dropdown.print-menu-opener
|
||||
%button.button.dropdown-button.icon-only
|
||||
%span.icon.attachment
|
||||
%ul.print-menu.dropdown-content
|
||||
%li
|
||||
- if PiecesJustificativesService.pieces_justificatives_total_size(dossier) < Dossier::TAILLE_MAX_ZIP
|
||||
= link_to "Télécharger toutes les pièces jointes", telecharger_pjs_gestionnaire_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link"
|
||||
- else
|
||||
%p.menu-item Le téléchargement des pièces jointes est désactivé pour les dossiers de plus de #{number_to_human_size Dossier::TAILLE_MAX_ZIP}.
|
||||
|
||||
|
||||
= render partial: "gestionnaires/procedures/dossier_actions", locals: { procedure: dossier.procedure, dossier: dossier, dossier_is_followed: current_gestionnaire&.follow?(dossier) }
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
= render partial: 'layouts/left_panels/left_panel_admin_procedurescontroller_navbar', locals: { active: 'MonAvis' }
|
5
app/views/layouts/mailers/_logo.html.haml
Normal file
5
app/views/layouts/mailers/_logo.html.haml
Normal file
|
@ -0,0 +1,5 @@
|
|||
- if url.present?
|
||||
%table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0" }
|
||||
%tr
|
||||
%td{ align: "center" }
|
||||
= image_tag url, height: "150", style: "display:block; max-height: 150px; max-width: 150px;"
|
34
app/views/layouts/mailers/_service_footer.html.haml
Normal file
34
app/views/layouts/mailers/_service_footer.html.haml
Normal file
|
@ -0,0 +1,34 @@
|
|||
%strong
|
||||
Merci de ne pas répondre à cet email.
|
||||
- if dossier.present? && dossier.messagerie_available?
|
||||
Pour vous adresser à votre administration, passez directement par la
|
||||
= succeed '.' do
|
||||
= link_to 'messagerie du dossier', messagerie_dossier_url(dossier), target: '_blank', rel: 'noopener'
|
||||
|
||||
- if service.present?
|
||||
%table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0", style: "cursor:auto;color:#55575d;font-family:Helvetica, Arial, sans-serif;font-size:11px;line-height:22px;text-align:left;" }
|
||||
%tr
|
||||
%td{ width: "50%", valign: "top" }
|
||||
%p
|
||||
%strong Cette démarche est gérée par :
|
||||
%br
|
||||
= service.nom
|
||||
%br
|
||||
= service.organisme
|
||||
%br
|
||||
= service.adresse
|
||||
%td{ width: "50%", valign: "top" }
|
||||
%p
|
||||
%strong Poser une question sur votre dossier :
|
||||
%br
|
||||
- if dossier.present? && dossier.messagerie_available?
|
||||
= link_to 'Par la messagerie', messagerie_dossier_url(dossier), target: '_blank', rel: 'noopener'
|
||||
- else
|
||||
Par email :
|
||||
= link_to service.email, "mailto:#{service.email}"
|
||||
%br
|
||||
Par téléphone :
|
||||
= link_to service.telephone, "tel:#{service.telephone}"
|
||||
%br
|
||||
Horaires : #{ formatted_horaires(service.horaires) }
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
- if @logo_url.present?
|
||||
- content_for :procedure_logo do
|
||||
%table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0" }
|
||||
%tr
|
||||
%td{ align: "center" }
|
||||
= image_tag @logo_url, height: "150", style: "display:block; max-height: 150px; max-width: 150px;"
|
||||
|
||||
- content_for :footer do
|
||||
%strong
|
||||
Merci de ne pas répondre à cet email.
|
||||
- if @dossier.present? && @dossier.messagerie_available?
|
||||
Pour vous adresser à votre administration, passez directement par la
|
||||
= succeed '.' do
|
||||
= link_to 'messagerie du dossier', messagerie_dossier_url(@dossier), target: '_blank', rel: 'noopener'
|
||||
|
||||
- if @service.present?
|
||||
%table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0", style: "cursor:auto;color:#55575d;font-family:Helvetica, Arial, sans-serif;font-size:11px;line-height:22px;text-align:left;" }
|
||||
%tr
|
||||
%td{ width: "50%", valign: "top" }
|
||||
%p
|
||||
%strong Cette démarche est gérée par :
|
||||
%br
|
||||
= @service.nom
|
||||
%br
|
||||
= @service.organisme
|
||||
%br
|
||||
= @service.adresse
|
||||
%td{ width: "50%", valign: "top" }
|
||||
%p
|
||||
%strong Poser une question sur votre dossier :
|
||||
%br
|
||||
- if @dossier.present? && @dossier.messagerie_available?
|
||||
= link_to 'Par la messagerie', messagerie_dossier_url(@dossier), target: '_blank', rel: 'noopener'
|
||||
- else
|
||||
Par email :
|
||||
= link_to @service.email, "mailto:#{@service.email}"
|
||||
%br
|
||||
Par téléphone :
|
||||
= link_to @service.telephone, "tel:#{@service.telephone}"
|
||||
%br
|
||||
Horaires : #{ formatted_horaires(@service.horaires) }
|
||||
|
||||
|
||||
= render template: 'layouts/mailers/notifications_layout'
|
|
@ -0,0 +1 @@
|
|||
= render partial: 'layouts/navbars/navbar_admin_procedurescontroller_index'
|
|
@ -0,0 +1 @@
|
|||
= render partial: 'layouts/navbars/navbar_admin_procedurescontroller_index'
|
|
@ -36,6 +36,7 @@ as well as a link to its edit page.
|
|||
<% if page.resource.invitation_expired? %>
|
||||
<%= link_to "renvoyer l'invitation", reinvite_manager_administrateur_path(page.resource), method: :post, class: "button" %>
|
||||
<% end %>
|
||||
<%= button_to "supprimer", delete_manager_administrateur_path(page.resource), method: :delete, disabled: !page.resource.can_be_deleted?, class: "button", data: { confirm: "Confirmez-vous la suppression de l'administrateur ?" }, title: page.resource.can_be_deleted? ? "Supprimer" : "Cet administrateur a des dossiers ou des procédures et ne peut être supprimé" %>
|
||||
</div>
|
||||
|
||||
</header>
|
||||
|
|
|
@ -7,4 +7,4 @@
|
|||
%p
|
||||
À tout moment, vous pouvez consulter votre dossier et les éventuels messages de l'administration à cette adresse : --lien dossier--
|
||||
|
||||
= render partial: "notification_mailer/signature"
|
||||
= render partial: "notification_mailer/default_templates/signature"
|
|
@ -10,4 +10,4 @@
|
|||
%p
|
||||
À tout moment, vous pouvez consulter votre dossier et les éventuels messages de l'administration à cette adresse : --lien dossier--
|
||||
|
||||
= render partial: "notification_mailer/signature"
|
||||
= render partial: "notification_mailer/default_templates/signature"
|
|
@ -7,4 +7,4 @@
|
|||
%p
|
||||
À tout moment, vous pouvez consulter votre dossier et les éventuels messages de l'administration à cette adresse : --lien dossier--
|
||||
|
||||
= render partial: "notification_mailer/signature"
|
||||
= render partial: "notification_mailer/default_templates/signature"
|
|
@ -4,4 +4,4 @@
|
|||
%p
|
||||
Votre administration vous confirme la bonne réception de votre dossier nº --numéro du dossier--. Celui-ci sera instruit dans le délai légal déclaré par votre interlocuteur.
|
||||
|
||||
= render partial: "notification_mailer/signature"
|
||||
= render partial: "notification_mailer/default_templates/signature"
|
|
@ -10,4 +10,4 @@
|
|||
%p
|
||||
Pour en savoir plus sur le motif du refus, vous pouvez consulter votre dossier et les éventuels messages de l'administration à cette adresse : --lien dossier--
|
||||
|
||||
= render partial: "notification_mailer/signature"
|
||||
= render partial: "notification_mailer/default_templates/signature"
|
|
@ -10,4 +10,4 @@
|
|||
%p
|
||||
Pour en savoir plus sur les raisons de ce classement sans suite, vous pouvez consulter votre dossier et les éventuels messages de l'administration à cette adresse : --lien dossier--
|
||||
|
||||
= render partial: "notification_mailer/signature"
|
||||
= render partial: "notification_mailer/default_templates/signature"
|
|
@ -0,0 +1,7 @@
|
|||
- content_for :procedure_logo do
|
||||
= render 'layouts/mailers/logo', url: @logo_url
|
||||
|
||||
= @rendered_template
|
||||
|
||||
- content_for :footer do
|
||||
= render 'layouts/mailers/service_footer', service: @service, dossier: @dossier
|
|
@ -18,6 +18,6 @@
|
|||
%br
|
||||
Nous utilisons pour cela <a href="https://matomo.org/" target="_blank" rel="noopener">Matomo</a>, un outil <a href="https://matomo.org/free-software/" target="_blank" rel="noopener">libre</a>, paramétré pour être en conformité avec la <a href="https://www.cnil.fr/fr/solutions-pour-la-mesure-daudience">recommandation « Cookies » </a>de la CNIL. Cela signifie que votre adresse IP, par exemple, est anonymisée avant d’être enregistrée. Il est donc impossible d’associer vos visites sur ce site à votre personne.
|
||||
|
||||
%h2.new-h2 Je contribue à enrichir vos données, puis-je y accéder ?
|
||||
%h2.new-h2 Comment désactiver le suivi statistique sur mon navigateur ?
|
||||
%p.new-p
|
||||
Bien sûr ! Les statistiques d’usage sont en accès libre sur <a href="https://stats.data.gouv.fr/index.php?module=MultiSites&action=index&idSite=1&period=range&date=previous30&updated=1#?idSite=1&period=range&date=previous30&category=Dashboard_Dashboard&subcategory=1&module=MultiSites&action=index" target="_blank" rel="noopener">stats.data.gouv.fr</a>.
|
||||
Si vous souhaitez désactiver ce suivi statistique, il vous suffit d’activer la fonctionnalité « Ne pas me pister » de votre navigateur. Notre outil de suivi le prendra en compte, et cessera d’inclure vos visites dans les statistiques.
|
||||
|
|
|
@ -23,4 +23,5 @@
|
|||
.flex.column.align-center
|
||||
= link_to 'Accéder à votre dossier', dossier_path(@dossier), class: 'button large primary'
|
||||
= link_to 'Déposer un autre dossier', procedure_lien(@dossier.procedure)
|
||||
.monavis
|
||||
!= @dossier.procedure.monavis_embed
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# API URLs
|
||||
API_ADRESSE_URL = ENV.fetch("API_ADRESSE_URL", "https://api-adresse.data.gouv.fr")
|
||||
API_CARTO_URL = ENV.fetch("API_CARTO_URL", "https://apicarto.sgmap.fr")
|
||||
API_CARTO_URL = ENV.fetch("API_CARTO_URL", "https://sandbox.geo.api.gouv.fr/apicarto")
|
||||
API_ENTREPRISE_URL = ENV.fetch("API_ENTREPRISE_URL", "https://entreprise.api.gouv.fr/v2")
|
||||
API_GEO_URL = ENV.fetch("API_GEO_URL", "https://geo.api.gouv.fr")
|
||||
API_GEO_SANDBOX_URL = ENV.fetch("API_GEO_SANDBOX_URL", "https://sandbox.geo.api.gouv.fr")
|
||||
|
|
|
@ -21,6 +21,7 @@ Rails.application.routes.draw do
|
|||
resources :administrateurs, only: [:index, :show, :new, :create] do
|
||||
post 'reinvite', on: :member
|
||||
put 'enable_feature', on: :member
|
||||
delete 'delete', on: :member
|
||||
end
|
||||
|
||||
resources :users, only: [:index, :show] do
|
||||
|
|
|
@ -5,7 +5,7 @@ describe ApiCarto::API do
|
|||
subject { described_class.search_qp(geojson) }
|
||||
|
||||
before do
|
||||
stub_request(:post, "https://apicarto.sgmap.fr/quartiers-prioritaires/search")
|
||||
stub_request(:post, "https://sandbox.geo.api.gouv.fr/apicarto/quartiers-prioritaires/search")
|
||||
.with(:body => /.*/,
|
||||
:headers => { 'Content-Type' => 'application/json' })
|
||||
.to_return(status: status, body: body)
|
||||
|
@ -53,7 +53,7 @@ describe ApiCarto::API do
|
|||
subject { described_class.search_cadastre(geojson) }
|
||||
|
||||
before do
|
||||
stub_request(:post, "https://apicarto.sgmap.fr/cadastre/geometrie")
|
||||
stub_request(:post, "https://sandbox.geo.api.gouv.fr/apicarto/cadastre/geometrie")
|
||||
.with(:body => /.*/,
|
||||
:headers => { 'Content-Type' => 'application/json' })
|
||||
.to_return(status: status, body: body)
|
||||
|
|
|
@ -4,7 +4,7 @@ describe ApiCarto::CadastreAdapter do
|
|||
subject { described_class.new(coordinates).results }
|
||||
|
||||
before do
|
||||
stub_request(:post, "https://apicarto.sgmap.fr/cadastre/geometrie")
|
||||
stub_request(:post, "https://sandbox.geo.api.gouv.fr/apicarto/cadastre/geometrie")
|
||||
.with(:body => /.*/,
|
||||
:headers => { 'Content-Type' => 'application/json' })
|
||||
.to_return(status: status, body: body)
|
||||
|
|
|
@ -4,7 +4,7 @@ describe ApiCarto::QuartiersPrioritairesAdapter do
|
|||
subject { described_class.new(coordinates).results }
|
||||
|
||||
before do
|
||||
stub_request(:post, "https://apicarto.sgmap.fr/quartiers-prioritaires/search")
|
||||
stub_request(:post, "https://sandbox.geo.api.gouv.fr/apicarto/quartiers-prioritaires/search")
|
||||
.with(:body => /.*/,
|
||||
:headers => { 'Content-Type' => 'application/json' })
|
||||
.to_return(status: status, body: body)
|
||||
|
|
|
@ -3,6 +3,12 @@ require "rails_helper"
|
|||
RSpec.describe DossierMailer, type: :mailer do
|
||||
let(:to_email) { 'gestionnaire@exemple.gouv.fr' }
|
||||
|
||||
shared_examples 'a dossier notification' do
|
||||
it 'includes the contact informations in the footer' do
|
||||
expect(subject.body).to include('ne pas répondre')
|
||||
end
|
||||
end
|
||||
|
||||
describe '.notify_new_draft' do
|
||||
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
|
||||
|
||||
|
@ -12,6 +18,8 @@ RSpec.describe DossierMailer, type: :mailer do
|
|||
it { expect(subject.subject).to include(dossier.procedure.libelle) }
|
||||
it { expect(subject.body).to include(dossier.procedure.libelle) }
|
||||
it { expect(subject.body).to include(dossier_url(dossier)) }
|
||||
|
||||
it_behaves_like 'a dossier notification'
|
||||
end
|
||||
|
||||
describe '.notify_new_answer' do
|
||||
|
@ -22,6 +30,8 @@ RSpec.describe DossierMailer, type: :mailer do
|
|||
it { expect(subject.subject).to include("Nouveau message") }
|
||||
it { expect(subject.subject).to include(dossier.id.to_s) }
|
||||
it { expect(subject.body).to include(messagerie_dossier_url(dossier)) }
|
||||
|
||||
it_behaves_like 'a dossier notification'
|
||||
end
|
||||
|
||||
describe '.notify_deletion_to_user' do
|
||||
|
|
|
@ -1,58 +1,55 @@
|
|||
require "spec_helper"
|
||||
|
||||
RSpec.describe NotificationMailer, type: :mailer do
|
||||
shared_examples_for "create a commentaire not notified" do
|
||||
it do
|
||||
expect { subject.deliver_now }.to change { Commentaire.count }.by(1)
|
||||
|
||||
subject.deliver_now
|
||||
commentaire = Commentaire.last
|
||||
expect(commentaire.body).to include(email_template.subject_for_dossier(dossier), email_template.body_for_dossier(dossier))
|
||||
expect(commentaire.dossier).to eq(dossier)
|
||||
end
|
||||
end
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:dossier) { create(:dossier, :with_service, :en_construction, user: user) }
|
||||
|
||||
describe '.send_notification' do
|
||||
let(:email_template) { instance_double('email_template', subject_for_dossier: 'subject', body_for_dossier: 'body') }
|
||||
|
||||
subject(:mail) do
|
||||
klass = Class.new(described_class) do
|
||||
# We’re testing the (private) method `NotificationMailer#send_notification`.
|
||||
#
|
||||
# The standard trick to test a private method would be to `send(:send_notification)`, but doesn’t work here,
|
||||
# because ActionMailer does some magic to expose public instance methods as class methods.
|
||||
# So, we use inheritance instead to make the private method public for testing purposes.
|
||||
def send_notification(dossier, template)
|
||||
super
|
||||
end
|
||||
end
|
||||
klass.send_notification(dossier, email_template)
|
||||
end
|
||||
|
||||
it { expect(mail.subject).to eq(email_template.subject_for_dossier) }
|
||||
it { expect(mail.body).to include(email_template.body_for_dossier) }
|
||||
it { expect(mail.body).to have_link('messagerie') }
|
||||
|
||||
it_behaves_like "create a commentaire not notified"
|
||||
end
|
||||
let(:procedure) { create(:simple_procedure) }
|
||||
let(:dossier) { create(:dossier, :en_construction, :for_individual, :with_service, user: user, procedure: procedure) }
|
||||
|
||||
describe '.send_dossier_received' do
|
||||
subject(:mail) { described_class.send_dossier_received(dossier) }
|
||||
let(:email_template) { create(:received_mail) }
|
||||
let(:email_template) { create(:received_mail, subject: 'Email subject', body: 'Your dossier was processed. Thanks.') }
|
||||
|
||||
before do
|
||||
dossier.procedure.received_mail = email_template
|
||||
end
|
||||
|
||||
it do
|
||||
expect(mail.subject).to eq(email_template.subject)
|
||||
expect(mail.body).to include(email_template.body)
|
||||
subject(:mail) { described_class.send_dossier_received(dossier) }
|
||||
|
||||
it 'creates a commentaire in the messagerie' do
|
||||
expect { subject.deliver_now }.to change { Commentaire.count }.by(1)
|
||||
|
||||
commentaire = Commentaire.last
|
||||
expect(commentaire.body).to include(email_template.subject_for_dossier(dossier), email_template.body_for_dossier(dossier))
|
||||
expect(commentaire.dossier).to eq(dossier)
|
||||
end
|
||||
|
||||
it 'renders the template' do
|
||||
expect(mail.subject).to eq('Email subject')
|
||||
expect(mail.body).to include('Your dossier was processed')
|
||||
expect(mail.body).to have_link('messagerie')
|
||||
end
|
||||
|
||||
it_behaves_like "create a commentaire not notified"
|
||||
context 'when the template body contains tags' do
|
||||
let(:email_template) { create(:received_mail, subject: 'Email subject', body: 'Hello --nom--, your dossier --lien dossier-- was processed.') }
|
||||
|
||||
it 'replaces value tags with the proper value' do
|
||||
expect(mail.body).to have_content(dossier.individual.nom)
|
||||
end
|
||||
|
||||
it 'replaces link tags with a clickable link' do
|
||||
expect(mail.body).to have_link(dossier_url(dossier))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the template body contains HTML' do
|
||||
let(:email_template) { create(:received_mail, body: 'Your <b>dossier</b> was processed. <iframe src="#">Foo</iframe>') }
|
||||
|
||||
it 'allows basic formatting tags' do
|
||||
expect(mail.body).to include('<b>dossier</b>')
|
||||
end
|
||||
|
||||
it 'sanitizes sensitive content' do
|
||||
expect(mail.body).not_to include('iframe')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue