Sha256: 1b80893b5efb829dbde8f06cb50bf4fdd6edf245c3b7bd59dbfeecf0572fe7a4

Contents?: true

Size: 940 Bytes

Versions: 10

Compression:

Stored size: 940 Bytes

Contents

require File.dirname(__FILE__) + '/test_helper'

context "scheduling jobs with hooks" do
  setup do
    Resque.redis.flushall
  end

  test "before_schedule hook that does not return false should be enqueued" do
    enqueue_time = Time.now
    SomeRealClass.expects(:before_schedule_example).with(:foo)
    SomeRealClass.expects(:after_schedule_example).with(:foo)
    Resque.enqueue_at(enqueue_time.to_i, SomeRealClass, :foo)
    assert_equal(1, Resque.delayed_timestamp_size(enqueue_time.to_i), "job should be enqueued")
  end

  test "before_schedule hook that returns false should not be enqueued" do
    enqueue_time = Time.now
    SomeRealClass.expects(:before_schedule_example).with(:foo).returns(false)
    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
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
resque-scheduler-2.3.1 test/scheduler_hooks_test.rb
resque-scheduler-2.3.0 test/scheduler_hooks_test.rb
resque-scheduler-2.2.0 test/scheduler_hooks_test.rb
resque-scheduler-2.1.1 test/scheduler_hooks_test.rb
resque-scheduler-2.1.0 test/scheduler_hooks_test.rb
resque-scheduler-2.0.1 test/scheduler_hooks_test.rb
nogara-resque-scheduler-2.0.2 test/scheduler_hooks_test.rb
nogara-resque-scheduler-2.0.1 test/scheduler_hooks_test.rb
resque-scheduler-2.0.0 test/scheduler_hooks_test.rb
resque-scheduler-2.0.0.h test/scheduler_hooks_test.rb