When a new PJ is uploaded enqueue a anti virus scan job
This commit is contained in:
parent
927cd3c6f4
commit
cd4615b10d
8 changed files with 105 additions and 0 deletions
32
spec/jobs/anti_virus_job_spec.rb
Normal file
32
spec/jobs/anti_virus_job_spec.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
RSpec.describe AntiVirusJob, type: :job do
|
||||
let(:champ) do
|
||||
champ = create(:champ, :piece_justificative)
|
||||
champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
|
||||
champ
|
||||
end
|
||||
let(:virus_scan) { create(:virus_scan, status: "pending", champ: champ, blob_key: champ.piece_justificative_file.blob.key) }
|
||||
|
||||
subject { AntiVirusJob.new.perform(virus_scan) }
|
||||
|
||||
context "when no virus is found" do
|
||||
let(:virus_found?) { true }
|
||||
|
||||
before do
|
||||
allow(ClamavService).to receive(:safe_file?).and_return(virus_found?)
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(virus_scan.reload.status).to eq("safe") }
|
||||
end
|
||||
|
||||
context "when a virus is found" do
|
||||
let(:virus_found?) { false }
|
||||
|
||||
before do
|
||||
allow(ClamavService).to receive(:safe_file?).and_return(virus_found?)
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(virus_scan.reload.status).to eq("infected") }
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue