Permalink
Browse files

test both sides of destroy_jobs behavior

  • Loading branch information...
1 parent b53ac48 commit a693dc9c578350d13988359c3e9c520e0ed97571 @defunkt defunkt committed Nov 1, 2008
Showing with 12 additions and 1 deletion.
  1. +12 −1 spec/job_spec.rb
View
@@ -90,7 +90,7 @@ def perform; raise 'did not work'; end
lambda { job.payload_object.perform }.should raise_error(Delayed::DeserializationError)
end
- it "should be failed if it failed more than MAX_ATTEMPTS times" do
+ it "should be failed if it failed more than MAX_ATTEMPTS times and we don't want to destroy jobs" do
default = Delayed::Job.destroy_jobs
Delayed::Job.destroy_jobs = false
@@ -102,6 +102,17 @@ def perform; raise 'did not work'; end
Delayed::Job.destroy_jobs = default
end
+ it "should be destroyed if it failed more than MAX_ATTEMPTS times and we want to destroy jobs" do
+ default = Delayed::Job.destroy_jobs
+ Delayed::Job.destroy_jobs = true
+
+ @job = Delayed::Job.create :payload_object => SimpleJob.new, :attempts => 50
+ @job.should_receive(:destroy)
+ @job.reschedule 'FAIL'
+
+ Delayed::Job.destroy_jobs = default
+ end
+
it "should never find failed jobs" do
@job = Delayed::Job.create :payload_object => SimpleJob.new, :attempts => 50, :failed_at => Time.now
Delayed::Job.find_available(1).length.should == 0

0 comments on commit a693dc9

Please sign in to comment.