From c4cd113fbdf46259a162f4c8ee533e3fc47737b6 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 23 Feb 2018 13:44:02 +0100 Subject: [PATCH 1/4] MailPreview: add send_dossier --- spec/mailers/previews/gestionnaire_mailer_preview.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/mailers/previews/gestionnaire_mailer_preview.rb b/spec/mailers/previews/gestionnaire_mailer_preview.rb index 2e62b4f5c..4fcf80f11 100644 --- a/spec/mailers/previews/gestionnaire_mailer_preview.rb +++ b/spec/mailers/previews/gestionnaire_mailer_preview.rb @@ -3,4 +3,8 @@ class GestionnaireMailerPreview < ActionMailer::Preview gestionnaire = Gestionnaire.first GestionnaireMailer.last_week_overview(gestionnaire, gestionnaire.last_week_overview) end + + def send_dossier + GestionnaireMailer.send_dossier(Gestionnaire.first, Dossier.first, Gestionnaire.last) + end end From 377e4d689a563c7a800b321e52b6c17a6b88a613 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 23 Feb 2018 13:09:57 +0100 Subject: [PATCH 2/4] Gestionnaire Namespace: fix send_dossier --- app/views/gestionnaire_mailer/send_dossier.text.erb | 2 +- spec/mailers/gestionnaire_mailer_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 spec/mailers/gestionnaire_mailer_spec.rb diff --git a/app/views/gestionnaire_mailer/send_dossier.text.erb b/app/views/gestionnaire_mailer/send_dossier.text.erb index 029fb2b4b..eb48dad51 100644 --- a/app/views/gestionnaire_mailer/send_dossier.text.erb +++ b/app/views/gestionnaire_mailer/send_dossier.text.erb @@ -2,7 +2,7 @@ Bonjour, <%= @sender.email %> vous a envoyé le dossier nº <%= @dossier.id %>, cliquez sur le lien ci-dessous pour y accéder : -<%= dossier_url(@dossier.procedure, @dossier) %> +<%= gestionnaire_dossier_url(@dossier.procedure, @dossier) %> Bonne journée, diff --git a/spec/mailers/gestionnaire_mailer_spec.rb b/spec/mailers/gestionnaire_mailer_spec.rb new file mode 100644 index 000000000..b39d5ce72 --- /dev/null +++ b/spec/mailers/gestionnaire_mailer_spec.rb @@ -0,0 +1,11 @@ +RSpec.describe GestionnaireMailer, type: :mailer do + describe '#send_dossier' do + let(:sender) { create(:gestionnaire) } + let(:recipient) { create(:gestionnaire) } + let(:dossier) { create(:dossier) } + + subject { described_class.send_dossier(sender, dossier, recipient) } + + it { expect(subject.body).to include('Bonjour') } + end +end From 4189a2790d1b9388b1f66eee1ea1b01af71e9d37 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 23 Feb 2018 13:44:34 +0100 Subject: [PATCH 3/4] MailPreview: fix last_week_overview --- spec/mailers/previews/gestionnaire_mailer_preview.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/mailers/previews/gestionnaire_mailer_preview.rb b/spec/mailers/previews/gestionnaire_mailer_preview.rb index 4fcf80f11..d38ca04e2 100644 --- a/spec/mailers/previews/gestionnaire_mailer_preview.rb +++ b/spec/mailers/previews/gestionnaire_mailer_preview.rb @@ -1,7 +1,7 @@ class GestionnaireMailerPreview < ActionMailer::Preview def last_week_overview gestionnaire = Gestionnaire.first - GestionnaireMailer.last_week_overview(gestionnaire, gestionnaire.last_week_overview) + GestionnaireMailer.last_week_overview(gestionnaire) end def send_dossier From 26c9f28407a56c1202917c1e393d1611a1334d81 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 23 Feb 2018 13:11:29 +0100 Subject: [PATCH 4/4] 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