specs: test de-serialization of job arguments
When the job is invoked directly, the serialization and de-serialization of the job arguments is not actually tested. Using `perform_later` inside a `perform_enqueued_jobs` allows to exercise the serialization.
This commit is contained in:
parent
a0df6e0ebb
commit
b82c269cef
1 changed files with 10 additions and 3 deletions
|
@ -1,11 +1,18 @@
|
|||
RSpec.describe VirusScannerJob, type: :job do
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
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.save
|
||||
champ
|
||||
end
|
||||
|
||||
subject { VirusScannerJob.new.perform(champ.piece_justificative_file.blob) }
|
||||
subject do
|
||||
perform_enqueued_jobs do
|
||||
VirusScannerJob.perform_later(champ.piece_justificative_file.blob)
|
||||
end
|
||||
end
|
||||
|
||||
context "when no virus is found" do
|
||||
let(:virus_found?) { true }
|
||||
|
@ -15,7 +22,7 @@ RSpec.describe VirusScannerJob, type: :job do
|
|||
subject
|
||||
end
|
||||
|
||||
it { expect(champ.piece_justificative_file.virus_scanner.safe?).to be_truthy }
|
||||
it { expect(champ.reload.piece_justificative_file.virus_scanner.safe?).to be_truthy }
|
||||
end
|
||||
|
||||
context "when a virus is found" do
|
||||
|
@ -26,6 +33,6 @@ RSpec.describe VirusScannerJob, type: :job do
|
|||
subject
|
||||
end
|
||||
|
||||
it { expect(champ.piece_justificative_file.virus_scanner.infected?).to be_truthy }
|
||||
it { expect(champ.reload.piece_justificative_file.virus_scanner.infected?).to be_truthy }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue