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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- resque-pause (0.0.2)
4
+ resque-pause (0.0.3)
5
5
  resque (>= 1.9.10)
6
6
 
7
7
  GEM
@@ -29,15 +29,17 @@ module ResquePause
29
29
  end
30
30
 
31
31
  post '/pause' do
32
- ResquePauseHelper.pause(params['queue_name']) unless params['queue_name'].empty?
33
- content_type :json
34
- encode(:queue_name => params['queue_name'], :paused => true)
35
- end
36
-
37
- post '/unpause' do
38
- ResquePauseHelper.unpause(params['queue_name']) unless params['queue_name'].empty?
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 => false)
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: url,
7
+ url: location.href,
9
8
  data: data,
10
9
  async: false,
11
10
  cache: false,
@@ -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)
@@ -1,7 +1,7 @@
1
1
  module Resque
2
2
  module Plugins
3
3
  module Pause
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
6
6
  end
7
7
  end
@@ -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 "/unpause", :queue_name => "queue2"
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 "/unpause", :queue_name => "queue2"
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Wandenberg Peixoto