resque_unit 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/resque_unit/resque.rb +20 -0
- data/test/resque_unit_test.rb +20 -0
- metadata +4 -4
data/lib/resque_unit/resque.rb
CHANGED
@@ -46,6 +46,19 @@ module Resque
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
# 1. Execute all jobs in all queues in an undefined order,
|
50
|
+
# 2. Check if new jobs were announced, and execute them.
|
51
|
+
# 3. Repeat 3
|
52
|
+
def self.full_run!
|
53
|
+
until empty_queues?
|
54
|
+
@queue.each do |k, v|
|
55
|
+
while job = v.shift
|
56
|
+
job[:klass].perform(*job[:args])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
49
62
|
# Returns the size of the given queue
|
50
63
|
def self.size(queue_name)
|
51
64
|
self.reset! unless @queue
|
@@ -65,4 +78,11 @@ module Resque
|
|
65
78
|
klass.instance_variable_get(:@queue) || (klass.respond_to?(:queue) && klass.queue)
|
66
79
|
end
|
67
80
|
|
81
|
+
# :nodoc:
|
82
|
+
def self.empty_queues?
|
83
|
+
@queue.all? do |k, v|
|
84
|
+
v.empty?
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
68
88
|
end
|
data/test/resque_unit_test.rb
CHANGED
@@ -135,6 +135,26 @@ class ResqueUnitTest < Test::Unit::TestCase
|
|
135
135
|
assert_queued(LowPriorityJob)
|
136
136
|
end
|
137
137
|
end
|
138
|
+
|
139
|
+
context ", when Resque.full_run!" do
|
140
|
+
setup do
|
141
|
+
assert !LowPriorityJob.run?, "The job should not have been run yet, did you call 'LowPriorityJob.run = false' in teardowns of other tests?"
|
142
|
+
Resque.full_run!
|
143
|
+
end
|
144
|
+
|
145
|
+
teardown do
|
146
|
+
LowPriorityJob.run = false
|
147
|
+
end
|
148
|
+
|
149
|
+
should "clear the jobs from the queue" do
|
150
|
+
assert_not_queued(JobThatCreatesANewJob)
|
151
|
+
assert_not_queued(LowPriorityJob)
|
152
|
+
end
|
153
|
+
|
154
|
+
should "run the new resque jobs" do
|
155
|
+
assert LowPriorityJob.run?, "LowPriorityJob should have been run"
|
156
|
+
end
|
157
|
+
end
|
138
158
|
end
|
139
159
|
|
140
160
|
context "A task in a different queue" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque_unit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 7
|
10
|
+
version: 0.2.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Weiss
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-29 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|