From 47cc0180bd23af2bbb18c2057f10c82612749aa4 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 23 May 2018 13:34:13 +0200 Subject: [PATCH 1/6] DubiousProcedure: change forbidden keywords --- app/jobs/find_dubious_procedures_job.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/jobs/find_dubious_procedures_job.rb b/app/jobs/find_dubious_procedures_job.rb index a1aa3dbba..22ac22f54 100644 --- a/app/jobs/find_dubious_procedures_job.rb +++ b/app/jobs/find_dubious_procedures_job.rb @@ -2,8 +2,9 @@ class FindDubiousProceduresJob < ApplicationJob queue_as :cron FORBIDDEN_KEYWORDS = [ - 'IBAN', 'NIR', 'NIRPP', 'race', 'religion', - 'carte bancaire', 'carte bleue', 'sécurité sociale' + 'NIR', 'NIRPP', 'race', 'religion', + 'carte bancaire', 'carte bleue', 'sécurité sociale', 'nationalité', + 'agdref', 'handicap', 'syndicat', 'politique' ] def perform(*args) From 6eadea29bc0861bb5365b721542d7e9a61cdd0f4 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 25 May 2018 08:29:36 +0200 Subject: [PATCH 2/6] [fix #1952] DubiousProcedure: add admin contact, procedure state and dossier count --- .../administration_mailer/dubious_procedures.html.haml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/views/administration_mailer/dubious_procedures.html.haml b/app/views/administration_mailer/dubious_procedures.html.haml index 2f90561c2..990e35bce 100644 --- a/app/views/administration_mailer/dubious_procedures.html.haml +++ b/app/views/administration_mailer/dubious_procedures.html.haml @@ -7,5 +7,12 @@ = link_to "Nº #{procedure.id},", manager_procedure_url(procedure)  #{procedure.libelle} : %b= type_de_champs.map(&:libelle).join(', ') + %br + État : #{procedure.aasm_state} + %br + Nombre de dossier : #{procedure.dossiers.count} + %br + Admin : + = link_to "#{procedure.administrateur.email}", "mailto:#{procedure.administrateur.email}" - else Il n'y a aucune procédure douteuse aujourd'hui From 959097ce8b331fd6b2794d8a7bb93dd9dd12c1a4 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 25 May 2018 08:30:23 +0200 Subject: [PATCH 3/6] DubiousProcedure: small style adjustement --- app/views/administration_mailer/dubious_procedures.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/administration_mailer/dubious_procedures.html.haml b/app/views/administration_mailer/dubious_procedures.html.haml index 990e35bce..07a0c842d 100644 --- a/app/views/administration_mailer/dubious_procedures.html.haml +++ b/app/views/administration_mailer/dubious_procedures.html.haml @@ -3,7 +3,7 @@ - if @procedures_and_type_de_champs.any? %ul - @procedures_and_type_de_champs.each do |procedure, type_de_champs| - %li + %li{ style: 'margin-bottom: 8px;' } = link_to "Nº #{procedure.id},", manager_procedure_url(procedure)  #{procedure.libelle} : %b= type_de_champs.map(&:libelle).join(', ') From 9f06308dbd0b0911e73dfc001a1348960bfdced0 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 25 May 2018 10:50:18 +0200 Subject: [PATCH 4/6] DubiousProcedure: ensure that hidden procedure are not detected --- spec/jobs/find_dubious_procedures_job_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/jobs/find_dubious_procedures_job_spec.rb b/spec/jobs/find_dubious_procedures_job_spec.rb index 2c1fb450a..06673367a 100644 --- a/spec/jobs/find_dubious_procedures_job_spec.rb +++ b/spec/jobs/find_dubious_procedures_job_spec.rb @@ -45,6 +45,12 @@ RSpec.describe FindDubiousProceduresJob, type: :job do it { expect(AdministrationMailer).to have_received(:dubious_procedures).with([]) } end + + context 'and a hidden procedure' do + let(:procedure) { create(:procedure, :hidden) } + + it { expect(AdministrationMailer).to have_received(:dubious_procedures).with([]) } + end end context 'with no suspicious champs' do From c00f56d45443c2be4dd82d3efb1a69381c1cf91c Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 30 May 2018 14:21:17 +0200 Subject: [PATCH 5/6] DubiousProcedure: improve spec --- spec/factories/procedure.rb | 6 ++++++ spec/jobs/find_dubious_procedures_job_spec.rb | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index 26446239d..233d655a0 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -119,6 +119,12 @@ FactoryBot.define do end end + trait :whitelisted do + after(:build) do |procedure, _evaluator| + procedure.update(whitelisted_at: DateTime.now) + end + end + trait :with_notice do after(:create) do |procedure, _evaluator| procedure.notice.attach( diff --git a/spec/jobs/find_dubious_procedures_job_spec.rb b/spec/jobs/find_dubious_procedures_job_spec.rb index 06673367a..eddba63a3 100644 --- a/spec/jobs/find_dubious_procedures_job_spec.rb +++ b/spec/jobs/find_dubious_procedures_job_spec.rb @@ -35,13 +35,13 @@ RSpec.describe FindDubiousProceduresJob, type: :job do end context 'and a whitelisted procedure' do - let(:procedure) { create(:procedure, whitelisted_at: DateTime.now) } + let(:procedure) { create(:procedure, :whitelisted) } it { expect(AdministrationMailer).to have_received(:dubious_procedures).with([]) } end context 'and a archived procedure' do - let(:procedure) { create(:procedure, archived_at: DateTime.now) } + let(:procedure) { create(:procedure, :archived) } it { expect(AdministrationMailer).to have_received(:dubious_procedures).with([]) } end From 66855e77b6b1f2b1172f36ed20f3b8ee47ae985a Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 30 May 2018 15:03:44 +0200 Subject: [PATCH 6/6] Guard for champ SIRET without etablissement --- app/views/new_gestionnaire/dossiers/_champs.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/new_gestionnaire/dossiers/_champs.html.haml b/app/views/new_gestionnaire/dossiers/_champs.html.haml index e980c11ec..a0e203778 100644 --- a/app/views/new_gestionnaire/dossiers/_champs.html.haml +++ b/app/views/new_gestionnaire/dossiers/_champs.html.haml @@ -51,7 +51,8 @@ = "#{c.libelle} :" %td.rich-text %span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) } - = render partial: "new_gestionnaire/dossiers/identite_entreprise", locals: { etablissement: c.etablissement } + - if c.etablissement.present? + = render partial: "new_gestionnaire/dossiers/identite_entreprise", locals: { etablissement: c.etablissement } - else %th.libelle = "#{c.libelle} :"