2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-05-16 12:20:24 +02:00
|
|
|
describe DubiousProcedure, type: :model do
|
|
|
|
describe '#all' do
|
2022-08-04 11:39:07 +02:00
|
|
|
let!(:procedure) { create(:procedure, types_de_champ_public: tdcs) }
|
|
|
|
let(:allowed_tdc) { { libelle: 'fournir' } }
|
2022-05-16 12:20:24 +02:00
|
|
|
subject { DubiousProcedure.all }
|
|
|
|
|
|
|
|
context 'with suspicious champs' do
|
|
|
|
let(:forbidden_tdcs) do
|
|
|
|
[
|
2022-08-04 11:39:07 +02:00
|
|
|
{ libelle: 'num de securite sociale, stp' },
|
|
|
|
{ libelle: "t'aurais une carte bancaire ?" }
|
2022-05-16 12:20:24 +02:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:tdcs) { forbidden_tdcs + [allowed_tdc] }
|
|
|
|
|
|
|
|
it 'returns dubious procedures' do
|
|
|
|
expect(subject.first.id).to eq(procedure.id)
|
|
|
|
expect(subject.first.libelle).to eq(procedure.libelle)
|
2022-10-11 11:44:29 +02:00
|
|
|
expect(subject.first.dubious_champs).to include("num de securite sociale, stp")
|
|
|
|
expect(subject.first.dubious_champs).to include("t'aurais une carte bancaire ?")
|
2022-05-16 12:20:24 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'and a whitelisted procedure' do
|
|
|
|
let(:procedure) { create(:procedure, :whitelisted) }
|
|
|
|
|
|
|
|
it { expect(subject).to eq([]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'and a closed procedure' do
|
|
|
|
let(:procedure) { create(:procedure, :closed) }
|
|
|
|
|
|
|
|
it { expect(subject).to eq([]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'and a discarded procedure' do
|
|
|
|
let(:procedure) { create(:procedure, :discarded) }
|
|
|
|
|
|
|
|
it { expect(subject).to eq([]) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with no suspicious champs' do
|
|
|
|
let(:tdcs) { [allowed_tdc] }
|
|
|
|
|
|
|
|
it { expect(subject).to eq([]) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|