21
1
Fork 0
mirror of https://github.com/Evolix/chexpire.git synced 2024-04-29 23:40:49 +02:00
chexpire/test/jobs/resync_job_test.rb
Colin Darie 717cd3fac3
Wrap first sync in a common job
Sometimes, when the first job is executed milliseconds after the insert, 
the db would not return it.
This way, we can safely perform another attempt.
2018-07-05 17:54:21 +02:00

32 lines
737 B
Ruby

require "test_helper"
class ReyncJobTest < ActiveJob::TestCase
test "enqueue a whois sync job" do
check = create(:check, :domain)
assert_enqueued_with(job: WhoisSyncJob, args: [check.id]) do
ResyncJob.perform_now(check.id)
end
end
test "enqueue a ssl sync job" do
check = create(:check, :ssl)
assert_enqueued_with(job: SSLSyncJob, args: [check.id]) do
ResyncJob.perform_now(check.id)
end
end
test "re enqueued job 5 times when check was not found" do
assert_enqueued_jobs 0
perform_enqueued_jobs(only: ResyncJob) do
assert_raise ActiveRecord::RecordNotFound do
ResyncJob.perform_now(9999)
end
end
assert_performed_jobs 5, only: ResyncJob
end
end