agent_propagate_job_spec.rb 710 B

123456789101112131415161718192021222324
  1. require 'rails_helper'
  2. describe AgentPropagateJob do
  3. it "calls Agent.receive! when run" do
  4. expect(Agent).to receive(:receive!)
  5. AgentPropagateJob.new.perform
  6. end
  7. context "#can_enqueue?" do
  8. it "is truthy when no propagation job is queued" do
  9. expect(AgentPropagateJob.can_enqueue?).to be_truthy
  10. end
  11. it "is falsy when a progation job is queued" do
  12. Delayed::Job.create!(queue: 'propagation')
  13. expect(AgentPropagateJob.can_enqueue?).to be_falsy
  14. end
  15. it "is truthy when a enqueued progation job failed" do
  16. Delayed::Job.create!(queue: 'propagation', failed_at: Time.now - 1.minute)
  17. expect(AgentPropagateJob.can_enqueue?).to be_truthy
  18. end
  19. end
  20. end