DubiousProcedureSpec: fix test (build 8212)

This commit is contained in:
simon lehericey 2018-03-27 11:31:35 +02:00
parent 7df3e0d05f
commit 32913aae55

View file

@ -7,8 +7,9 @@ RSpec.describe FindDubiousProceduresJob, type: :job do
let(:allowed_tdc) { create(:type_de_champ, libelle: 'fournir') } let(:allowed_tdc) { create(:type_de_champ, libelle: 'fournir') }
before do before do
allow(AdministrationMailer).to receive(:dubious_procedures) allow(AdministrationMailer).to receive(:dubious_procedures) do |arg|
.and_return(mailer_double) @dubious_procedures_args = arg
end.and_return(mailer_double)
procedure.types_de_champ << tdcs procedure.types_de_champ << tdcs
FindDubiousProceduresJob.new.perform FindDubiousProceduresJob.new.perform
@ -25,8 +26,10 @@ RSpec.describe FindDubiousProceduresJob, type: :job do
let(:tdcs) { forbidden_tdcs + [allowed_tdc] } let(:tdcs) { forbidden_tdcs + [allowed_tdc] }
it 'mails tech about the dubious procedure' do it 'mails tech about the dubious procedure' do
expect(AdministrationMailer).to have_received(:dubious_procedures) receive_procedure, receive_forbidden_tdcs = @dubious_procedures_args[0]
.with([[procedure, forbidden_tdcs]])
expect(receive_procedure).to eq(procedure)
expect(receive_forbidden_tdcs).to match(forbidden_tdcs)
end end
context 'and a whitelisted procedure' do context 'and a whitelisted procedure' do