From 26c9f28407a56c1202917c1e393d1611a1334d81 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 23 Feb 2018 13:11:29 +0100 Subject: [PATCH] Gestionnaire Namespace: fix last_week_overview --- .../last_week_overview.html.haml | 6 ++-- spec/mailers/gestionnaire_mailer_spec.rb | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/app/views/gestionnaire_mailer/last_week_overview.html.haml b/app/views/gestionnaire_mailer/last_week_overview.html.haml index 0e00edd7c..3e91be452 100644 --- a/app/views/gestionnaire_mailer/last_week_overview.html.haml +++ b/app/views/gestionnaire_mailer/last_week_overview.html.haml @@ -4,7 +4,7 @@ %h2{ style: 'font-size: 20px; font-weight: 300; margin: 25px 0 5px;' } #{procedure_overview.procedure.libelle} - = link_to 'voir', procedure_url(procedure_overview.procedure), style: 'color: #4393F3; font-size: 14px;' + = link_to 'voir', gestionnaire_procedure_url(procedure_overview.procedure), style: 'color: #4393F3; font-size: 14px;' %table{ cellpadding: '0', cellspacing: '0', style: 'width: 100%; padding-bottom: 20px;' } %tbody @@ -24,7 +24,7 @@ - if procedure_overview.old_dossiers_en_construction.count < 6 \: - old_dossiers_en_construction = procedure_overview.old_dossiers_en_construction.map do |old_dossier| - - link_to "nº #{old_dossier.id}", dossier_url(procedure_overview.procedure, old_dossier), style: 'color: #4393F3;' + - link_to "nº #{old_dossier.id}", gestionnaire_dossier_url(procedure_overview.procedure, old_dossier), style: 'color: #4393F3;' - end.join(', ') = sanitize(old_dossiers_en_construction, attributes: %w(href style)) @@ -38,7 +38,7 @@ - if procedure_overview.old_dossiers_en_instruction.count < 6 \: - old_dossiers_en_instruction = procedure_overview.old_dossiers_en_instruction.map do |old_dossier| - - link_to "nº #{old_dossier.id}", dossier_url(procedure_overview.procedure, old_dossier), style: 'color: #4393F3;' + - link_to "nº #{old_dossier.id}", gestionnaire_dossier_url(procedure_overview.procedure, old_dossier), style: 'color: #4393F3;' - end.join(', ') = sanitize(old_dossiers_en_instruction, attributes: %w(href style)) diff --git a/spec/mailers/gestionnaire_mailer_spec.rb b/spec/mailers/gestionnaire_mailer_spec.rb index b39d5ce72..1a55cf8c1 100644 --- a/spec/mailers/gestionnaire_mailer_spec.rb +++ b/spec/mailers/gestionnaire_mailer_spec.rb @@ -8,4 +8,32 @@ RSpec.describe GestionnaireMailer, type: :mailer do it { expect(subject.body).to include('Bonjour') } end + + describe '#last_week_overview' do + let(:gestionnaire) { create(:gestionnaire) } + let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } + let(:dossier) { create(:dossier) } + let(:last_week_overview) do + procedure_overview = double('po', + procedure: procedure, + created_dossiers_count: 0, + dossiers_en_construction_count: 1, + old_dossiers_en_construction: [dossier], + dossiers_en_construction_description: 'desc', + dossiers_en_instruction_count: 1, + old_dossiers_en_instruction: [dossier], + dossiers_en_instruction_description: 'desc') + + { + start_date: DateTime.now, + procedure_overviews: [procedure_overview] + } + end + + before { allow(gestionnaire).to receive(:last_week_overview).and_return(last_week_overview) } + + subject { described_class.last_week_overview(gestionnaire) } + + it { expect(subject.body).to include('Vos activités') } + end end