resque-pause 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/resque_pause/server.rb +10 -8
- data/lib/resque_pause/server/public/pause.js +2 -3
- data/lib/resque_pause_helper.rb +1 -1
- data/lib/version.rb +1 -1
- data/spec/resque-web_spec.rb +4 -4
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/resque_pause/server.rb
CHANGED
@@ -29,15 +29,17 @@ module ResquePause
|
|
29
29
|
end
|
30
30
|
|
31
31
|
post '/pause' do
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
pause = params['pause'] == "true"
|
33
|
+
|
34
|
+
unless params['queue_name'].empty?
|
35
|
+
if pause
|
36
|
+
ResquePauseHelper.pause(params['queue_name'])
|
37
|
+
else
|
38
|
+
ResquePauseHelper.unpause(params['queue_name'])
|
39
|
+
end
|
40
|
+
end
|
39
41
|
content_type :json
|
40
|
-
encode(:queue_name => params['queue_name'], :paused =>
|
42
|
+
encode(:queue_name => params['queue_name'], :paused => pause)
|
41
43
|
end
|
42
44
|
|
43
45
|
get /pause\/public\/([a-z]+\.[a-z]+)/ do
|
@@ -1,11 +1,10 @@
|
|
1
1
|
jQuery(document).ready(function($) {
|
2
2
|
$('input:checkbox.pause').click( function(){
|
3
3
|
var queue = $(this);
|
4
|
-
var data = {'queue_name': queue.val()};
|
5
|
-
var url = queue.is(':checked') ? '/pause' : '/unpause';
|
4
|
+
var data = {'queue_name': queue.val(), 'pause': queue.is(':checked')};
|
6
5
|
$.ajax({
|
7
6
|
type: 'POST',
|
8
|
-
url:
|
7
|
+
url: location.href,
|
9
8
|
data: data,
|
10
9
|
async: false,
|
11
10
|
cache: false,
|
data/lib/resque_pause_helper.rb
CHANGED
@@ -13,7 +13,7 @@ module ResquePauseHelper
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def enqueue_job(args)
|
16
|
-
Resque.redis.lpush("queue:#{args[:queue]}", Resque.encode(:class => args[:class], :args => args[:args]))
|
16
|
+
Resque.redis.lpush("queue:#{args[:queue]}", Resque.encode(:class => args[:class].to_s, :args => args[:args]))
|
17
17
|
end
|
18
18
|
|
19
19
|
def dequeue_job(args)
|
data/lib/version.rb
CHANGED
data/spec/resque-web_spec.rb
CHANGED
@@ -39,13 +39,13 @@ describe ResquePause::Server do
|
|
39
39
|
|
40
40
|
|
41
41
|
it "should pause a queue" do
|
42
|
-
post "/pause", :queue_name => "queue3"
|
42
|
+
post "/pause", :queue_name => "queue3", :pause => true
|
43
43
|
|
44
44
|
ResquePauseHelper.paused?("queue3").should be_true
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should return a json when pause a queue" do
|
48
|
-
post "/pause", :queue_name => "queue3"
|
48
|
+
post "/pause", :queue_name => "queue3", :pause => true
|
49
49
|
|
50
50
|
last_response.headers["Content-Type"].should == "application/json"
|
51
51
|
last_response.body.should == { :queue_name => "queue3", :paused => true }.to_json
|
@@ -53,13 +53,13 @@ describe ResquePause::Server do
|
|
53
53
|
|
54
54
|
it "should unpause a queue" do
|
55
55
|
ResquePauseHelper.pause("queue2")
|
56
|
-
post "/
|
56
|
+
post "/pause", :queue_name => "queue2", :pause => false
|
57
57
|
|
58
58
|
ResquePauseHelper.paused?("queue2").should be_false
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should return a json when unpause a queue" do
|
62
|
-
post "/
|
62
|
+
post "/pause", :queue_name => "queue2", :pause => false
|
63
63
|
|
64
64
|
last_response.headers["Content-Type"].should == "application/json"
|
65
65
|
last_response.body.should == { :queue_name => "queue2", :paused => false }.to_json
|