smq 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/smq/queue.rb +1 -1
- data/test/test_queue.rb +10 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/smq/queue.rb
CHANGED
@@ -58,7 +58,7 @@ module SMQ
|
|
58
58
|
|
59
59
|
def delete_queue_items(where = nil, limit = nil)
|
60
60
|
# delete_all doesn't support a :limit clause, so we have to fake it
|
61
|
-
msg = SMQ::Message.find(:first, :offset => limit) if !limit.nil?
|
61
|
+
msg = SMQ::Message.find(:first, :select => 'id', :conditions => ["queue = ?", @name], :offset => limit) if !limit.nil?
|
62
62
|
if (msg.nil?)
|
63
63
|
SMQ::Message.delete_all(["queue = ? #{where ? 'AND ' + where : ''}", @name])
|
64
64
|
else
|
data/test/test_queue.rb
CHANGED
@@ -63,6 +63,13 @@ class QueueTest < Test::Unit::TestCase
|
|
63
63
|
assert_equal 4, SMQ::Message.count(:conditions => ["queue = ?", @queue.name])
|
64
64
|
end
|
65
65
|
|
66
|
+
def test_clearing_completed_should_limit_correctly_with_more_than_one_queue
|
67
|
+
populate_and_ack_all_but_fail_one SMQ::Queue.new("another_queue")
|
68
|
+
populate_and_ack_all_but_fail_one
|
69
|
+
@queue.clear_completed! 2
|
70
|
+
assert_equal 3, SMQ::Message.count(:conditions => ["queue = ?", @queue.name])
|
71
|
+
end
|
72
|
+
|
66
73
|
def test_clearing_failures_should_not_touch_successful_messages
|
67
74
|
populate_and_ack_all_but_fail_one
|
68
75
|
@queue.clear_failed!
|
@@ -84,8 +91,9 @@ class QueueTest < Test::Unit::TestCase
|
|
84
91
|
|
85
92
|
private
|
86
93
|
|
87
|
-
def populate_and_ack_all_but_fail_one
|
88
|
-
|
94
|
+
def populate_and_ack_all_but_fail_one(queue = nil)
|
95
|
+
queue ||= @queue
|
96
|
+
populate_queue(queue, 5)
|
89
97
|
msg = SMQ::Message.find(:first)
|
90
98
|
msg.fail
|
91
99
|
msg.save!
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Tim Blair
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-04-08 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|