test/resque/resque_test.rb in resque-throttle-0.2.19 vs test/resque/resque_test.rb in resque-throttle-0.3.0
- old
+ new
@@ -2,20 +2,20 @@
class ResqueTest < Test::Unit::TestCase
context "Resque" do
setup do
- Resque.redis.flush_all
+ flush_all
assert_nil Resque.redis.get(OneHourThrottledJob.key)
@bogus_args = "bogus_arg"
end
context "#enqueue" do
should "add a throttled job key to the set with the proper TTL (Expire)" do
- Resque.expects(:enqueue_without_throttle).returns(true)
+ Resque.expects(:enqueue_without_throttle).returns(true)
assert Resque.enqueue(IdentifierThrottledJob, @bogus_args)
- assert Resque.redis.keys('*').include?("resque:IdentifierThrottledJob:my_bogus_arg")
+ assert Resque.redis.keys('*').include?("IdentifierThrottledJob:my_bogus_arg")
assert_equal 3600, Resque.redis.ttl(IdentifierThrottledJob.key(@bogus_args))
end
context "job has not reached throttle limit" do
should "not add another job to the queue and raise a throttled exception" do
@@ -27,7 +27,11 @@
should "enqueue a job without throttling if the job is disabled" do
Resque.expects(:enqueue_without_throttle).twice
2.times { Resque.enqueue(DisabledThrottledJob, @bogus_args) }
end
end
+ end
+
+ def flush_all
+ Resque.redis.respond_to?(:flushall) ? Resque.redis.flushall : Resque.redis.flush_all
end
end
\ No newline at end of file