tests
This commit is contained in:
parent
9ee9389ba1
commit
1b27ab5aff
1 changed files with 49 additions and 39 deletions
|
@ -7,15 +7,26 @@ describe VirusScannerJob, type: :job do
|
||||||
VirusScannerJob.perform_now(blob)
|
VirusScannerJob.perform_now(blob)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the blob is not analyzed yet" do
|
context "when the virus scan launch before rails analyze" do
|
||||||
it "retries the job later" do
|
before do
|
||||||
expect { subject }.to have_enqueued_job(VirusScannerJob)
|
allow(ClamavService).to receive(:safe_file?).and_return(true)
|
||||||
|
subject
|
||||||
|
blob.analyze
|
||||||
end
|
end
|
||||||
|
it { expect(blob.virus_scanner.safe?).to be_truthy }
|
||||||
|
it { expect(blob.analyzed?).to be_truthy }
|
||||||
|
it { expect(blob.lock_version).to eq(2) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the blob has been analyzed" do
|
context "should raise ActiveRecord::StaleObjectError" do
|
||||||
|
let(:blob_2) { ActiveStorage::Blob.find(blob.id) }
|
||||||
before do
|
before do
|
||||||
blob.analyze
|
blob_2.metadata[:virus_scan_result] = "infected"
|
||||||
|
blob.metadata[:virus_scan_result] = "safe"
|
||||||
|
blob.save
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect { blob_2.save }.to raise_error(ActiveRecord::StaleObjectError) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when there is an integrity error" do
|
context "when there is an integrity error" do
|
||||||
|
@ -60,4 +71,3 @@ describe VirusScannerJob, type: :job do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue