test/scheduler_hooks_test.rb in resque-scheduler-4.1.0 vs test/scheduler_hooks_test.rb in resque-scheduler-4.2.0
- old
+ new
@@ -19,6 +19,37 @@
SomeRealClass.expects(:after_schedule_example).never
Resque.enqueue_at(enqueue_time.to_i, SomeRealClass, :foo)
assert_equal(0, Resque.delayed_timestamp_size(enqueue_time.to_i),
'job should not be enqueued')
end
+
+ test 'default failure hooks are called when enqueueing a job fails' do
+ config = {
+ 'cron' => '* * * * *',
+ 'class' => 'SomeRealClass',
+ 'args' => '/tmp'
+ }
+
+ e = RuntimeError.new('custom error')
+ Resque::Scheduler.expects(:enqueue_from_config).raises(e)
+
+ Resque::Scheduler::FailureHandler.expects(:on_enqueue_failure).with(config, e)
+ Resque::Scheduler.enqueue(config)
+ end
+
+ test 'failure hooks are called when enqueueing a job fails' do
+ with_failure_handler(ExceptionHandlerClass) do
+ config = {
+ 'cron' => '* * * * *',
+ 'class' => 'SomeRealClass',
+ 'args' => '/tmp'
+ }
+
+ e = RuntimeError.new('custom error')
+ Resque::Scheduler.expects(:enqueue_from_config).raises(e)
+
+ ExceptionHandlerClass.expects(:on_enqueue_failure).with(config, e)
+
+ Resque::Scheduler.enqueue(config)
+ end
+ end
end