No dubious proc. email == Everything is ok || Something went wrong. We should always send dubious procedure email.

This commit is contained in:
Mathieu Magnin 2018-05-07 12:24:05 +02:00
parent 9f8083f69c
commit 7f4e6eae6b
3 changed files with 15 additions and 12 deletions

View file

@ -24,8 +24,6 @@ class FindDubiousProceduresJob < ApplicationJob
.group_by(&:procedure_id)
.map { |_procedure_id, tdcs| [tdcs[0].procedure, tdcs] }
if dubious_procedures_and_tdcs.present?
AdministrationMailer.dubious_procedures(dubious_procedures_and_tdcs).deliver_now
end
AdministrationMailer.dubious_procedures(dubious_procedures_and_tdcs).deliver_now
end
end

View file

@ -1,8 +1,11 @@
- content_for(:title, 'Liste de procédures douteuses')
%ul
- @procedures_and_type_de_champs.each do |procedure, type_de_champs|
%li
= link_to "Nº #{procedure.id},", manager_procedure_url(procedure)
 #{procedure.libelle} :
%b= type_de_champs.map(&:libelle).join(', ')
- if @procedures_and_type_de_champs.any?
%ul
- @procedures_and_type_de_champs.each do |procedure, type_de_champs|
%li
= link_to "Nº #{procedure.id},", manager_procedure_url(procedure)
 #{procedure.libelle} :
%b= type_de_champs.map(&:libelle).join(', ')
- else
Il n'y a aucune procédure douteuse aujourd'hui

View file

@ -30,25 +30,27 @@ RSpec.describe FindDubiousProceduresJob, type: :job do
expect(receive_procedure).to eq(procedure)
expect(receive_forbidden_tdcs).to match(forbidden_tdcs)
expect(AdministrationMailer).to have_received(:dubious_procedures).with(@dubious_procedures_args)
end
context 'and a whitelisted procedure' do
let(:procedure) { create(:procedure, whitelisted_at: DateTime.now) }
it { expect(AdministrationMailer).not_to have_received(:dubious_procedures) }
it { expect(AdministrationMailer).to have_received(:dubious_procedures).with([]) }
end
context 'and a archived procedure' do
let(:procedure) { create(:procedure, archived_at: DateTime.now) }
it { expect(AdministrationMailer).not_to have_received(:dubious_procedures) }
it { expect(AdministrationMailer).to have_received(:dubious_procedures).with([]) }
end
end
context 'with no suspicious champs' do
let(:tdcs) { [allowed_tdc] }
it { expect(AdministrationMailer).not_to receive(:dubious_procedures) }
it { expect(AdministrationMailer).to have_received(:dubious_procedures).with([]) }
end
end
end