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
|
RSpec.describe VirusScannerJob, type: :job do
|
||||||
|
include ActiveJob::TestHelper
|
||||||
|
|
||||||
let(:champ) do
|
let(:champ) do
|
||||||
champ = create(:champ, :piece_justificative)
|
champ = create(:champ, :piece_justificative)
|
||||||
champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
|
champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
|
||||||
|
champ.save
|
||||||
champ
|
champ
|
||||||
end
|
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
|
context "when no virus is found" do
|
||||||
let(:virus_found?) { true }
|
let(:virus_found?) { true }
|
||||||
|
@ -15,7 +22,7 @@ RSpec.describe VirusScannerJob, type: :job do
|
||||||
subject
|
subject
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context "when a virus is found" do
|
context "when a virus is found" do
|
||||||
|
@ -26,6 +33,6 @@ RSpec.describe VirusScannerJob, type: :job do
|
||||||
subject
|
subject
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue