Skip to content

Commit ee8c764

Browse files
committed
add Queue#destroyed?
1 parent 2be2099 commit ee8c764

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/resque/queue.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ def destroy
8888
@redis.srem(:queues, @name)
8989
end
9090

91+
# returns +true+ if the queue is destroyed and +false+ if it isn't
92+
def destroyed?
93+
!@redis.sismember(:queues, @name)
94+
end
95+
9196
def encode object
9297
@coder.dump object
9398
end

test/redis_queue_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ def == other
9898
assert !Resque.redis.exists(queue.redis_name)
9999
end
100100

101+
it "returns false if a queue is not destroyed" do
102+
assert !q.destroyed?
103+
end
104+
105+
it "returns true if a queue is destroyed" do
106+
queue1 = q
107+
queue1.destroy
108+
assert queue1.destroyed?
109+
end
110+
101111
def q
102112
Resque::Queue.new 'foo', Resque.redis
103113
end

0 commit comments

Comments
 (0)