resque-rate_limited_queue 1.0.2 → 1.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10b17055e5a285f6724e2bb8b857e8258b78dfd5
4
- data.tar.gz: 144bf7bb14973f0e3e1a317c58aff1f46965c4f6
3
+ metadata.gz: e3d514482bdda5f90ef98a9d898bfe9cc2bd3a4c
4
+ data.tar.gz: 0f2162ec01cb03476e918d62545a5fc9081000e9
5
5
  SHA512:
6
- metadata.gz: 048a567b7ffc945ec45334e215c55f86596569f9780b1e3564b067b4fb83935ab08e5fdde8a0a79f339a2226900d15f67014c0daba1f31c636e01a03d148597a
7
- data.tar.gz: 294537d08ab7611a9611658d4ae53fdaad4b3bbb37e73d936004cec4fb4dcdba82f6cbdf29ef05a1bf19b9e3a812d625b14ac8b52a8c38a5aa00cd4a312af475
6
+ metadata.gz: a688b780cffbef935aea3a5d7a6402c255e3933e91bb9367bd18b830a76669b209afdf9c74f4b97ce883e1aad1382b0f7df68592762ffe0f18665b6b196e2d29
7
+ data.tar.gz: 183fa3c3080f6de61da2d9d157666fa078ea094c025658993ed6e1097b7482bb8f61013148a13ebaf8b944695a1f623a5d4bb4891a87254523afd2c940a14722
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
+ .ruby-gemset
2
+ .ruby-version
1
3
  /.bundle/
2
4
  /.yardoc
3
5
  /Gemfile.lock
data/README.md CHANGED
@@ -148,8 +148,7 @@ All the functions are class methods
148
148
  rate_limited_enqueue(klass, *params)
149
149
  rate_limited_requeue(klass, *params)
150
150
  ````
151
- Queue the job specified to the resque queue specified by `@queue`. `rate_limited_requeue` is intended for use when you need the job to be pushed back to the queue; there are two reasons to split this from `queue`. Firstly it makes testing easier - secondly there is a boundary condition when you need to requeue the last job in the queue.
152
- `, but they are split to make testing with stubs easier.
151
+ Queue the job specified to the resque queue specified by `@queue`. `rate_limited_requeue` is intended for use when you need the job to be pushed back to the queue; there are two reasons to split this from `rate_limited_enqueue`. Firstly it makes testing with stubs easier - secondly there is a boundary condition when you need to requeue the last job in the queue.
153
152
 
154
153
  ```ruby
155
154
  pause
@@ -57,7 +57,9 @@ module Resque
57
57
 
58
58
  def paused?(unknown = false)
59
59
  # parameter is what to return if the queue is empty, and so the state is unknown
60
- if Resque.redis.exists(RESQUE_PREFIX + @queue.to_s)
60
+ if Resque.inline
61
+ false
62
+ elsif Resque.redis.exists(RESQUE_PREFIX + @queue.to_s)
61
63
  false
62
64
  elsif Resque.redis.exists(RESQUE_PREFIX + paused_queue_name)
63
65
  true
@@ -1,3 +1,3 @@
1
1
  module RateLimitedQueue
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
@@ -118,6 +118,38 @@ describe Resque::Plugins::RateLimitedQueue do
118
118
  end
119
119
  end
120
120
 
121
+ describe 'when queue is paused and Resque is in inline mode' do
122
+ let(:resque_prefix) { Resque::Plugins::RateLimitedQueue::RESQUE_PREFIX }
123
+ let(:queue) { resque_prefix + RateLimitedTestQueue.queue_name_private }
124
+ let(:paused_queue) { resque_prefix + RateLimitedTestQueue.paused_queue_name }
125
+
126
+ before do
127
+ Resque.redis.stub(:exists).with(queue).and_return(false)
128
+ Resque.redis.stub(:exists).with(paused_queue).and_return(true)
129
+ Resque.inline = true
130
+ end
131
+
132
+ after do
133
+ Resque.inline = false
134
+ end
135
+
136
+ it 'would be paused' do
137
+ expect(Resque.redis.exists(queue)).to eq false
138
+ expect(Resque.redis.exists(paused_queue)).to eq true
139
+ end
140
+
141
+ it 'says it is not paused' do
142
+ expect(RateLimitedTestQueue.paused?).to eq false
143
+ end
144
+
145
+ it 'performs the job' do
146
+ expect do
147
+ # Stack overflow unless handled
148
+ RateLimitedTestQueue.rate_limited_enqueue(RateLimitedTestQueue, true)
149
+ end.not_to raise_error
150
+ end
151
+ end
152
+
121
153
  describe 'find_class' do
122
154
  it 'works with symbol' do
123
155
  RateLimitedTestQueue.find_class(RateLimitedTestQueue).should eq RateLimitedTestQueue
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-rate_limited_queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Dowling
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-26 00:00:00.000000000 Z
11
+ date: 2015-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: resque