sidekiq-failures 0.4.0 → 0.4.1

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: 1e3a32d193a70834983a509cda264943a04cf76d
4
- data.tar.gz: 946c4d36eab67ffd4b16b1e4e5dece3699be0f5a
3
+ metadata.gz: 71027ff19b10b529acabafaba413fb8e6c79cd94
4
+ data.tar.gz: b8d994984de5da5050c78962704169f30f6c4e60
5
5
  SHA512:
6
- metadata.gz: 322bccce2ceacf773accdc94f9f693fc4c74286308aa2470cde98b731fedace3497514114161851194b074c44aa09179c36cc7824523297ad7b31da0480b2a05
7
- data.tar.gz: ef0caebd8929b2f98bb1a7956bfea0b9806198bb72f29d3ee971e7381d44b68b8fea6766aba82c8c3813ec0ad41d9b4ea05b5da773aea4d9d60bd913922c082a
6
+ metadata.gz: 5eb5e39114e6a384d8285dd6e9e4d32d62d6dc8adbfaa76c55af1f7bce617bb93fc5242cba0c24c87168ec7d7fa450880d602e7f06b341d09f378aefb73957f6
7
+ data.tar.gz: d5e89bad2b074dedc2d64976becae9d30651aae28c55799572c3870db87de42c4f8e8b1903f4d50f9fdb0b8c97b6959cc5ae88e95db41615ac981e77e8981d56
@@ -1,5 +1,8 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 0.4.1
4
+ * Restore compatibility for failed payloads created with 0.3.0
5
+
3
6
  ## 0.4.0
4
7
  * Bump sidekiq dependency to sidekiq >= 2.16.0
5
8
  * Introduce delete(all) / retry(all) (@spectator)
@@ -1,5 +1,14 @@
1
1
  module Sidekiq
2
2
  class SortedEntry
3
+ alias_method :super_initialize, :initialize
4
+
5
+ def initialize(parent, score, item)
6
+ super_initialize(parent, score, item)
7
+
8
+ # 0.3.0 compatibility
9
+ @item.merge!(@item["payload"]) if @item["payload"]
10
+ end
11
+
3
12
  def retry_failure
4
13
  Sidekiq.redis do |conn|
5
14
  results = conn.zrangebyscore(Sidekiq::Failures::LIST_KEY, score, score)
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Failures
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1"
4
4
  end
5
5
  end
@@ -135,6 +135,39 @@ module Sidekiq
135
135
  end
136
136
  end
137
137
 
138
+ describe 'when there are failures with deprecated format' do
139
+ before do
140
+ create_sample_failure(args: nil, payload: { args: ['bob', 5] })
141
+ get '/failures'
142
+ end
143
+
144
+ it 'should be successful' do
145
+ last_response.status.must_equal 200
146
+ end
147
+
148
+ it 'can display failures page with failures listed' do
149
+ last_response.body.must_match /Failed Jobs/
150
+ last_response.body.must_match /HardWorker/
151
+ last_response.body.must_match /ArgumentError/
152
+ last_response.body.wont_match /No failed jobs found/
153
+ end
154
+ end
155
+
156
+ describe 'when there are failures with unescaped data' do
157
+ before do
158
+ create_sample_failure(args: ['<h1>omg</h1>'], error_message: '<p>wow</p>')
159
+ get '/failures'
160
+ end
161
+
162
+ it 'can escape arguments' do
163
+ last_response.body.must_match /&quot;&lt;h1&gt;omg&lt;&#x2F;h1&gt;&quot;/
164
+ end
165
+
166
+ it 'can escape error message' do
167
+ last_response.body.must_match /ArgumentError: &lt;p&gt;wow&lt;&#x2F;p&gt;/
168
+ end
169
+ end
170
+
138
171
  describe 'when there is failure' do
139
172
  before do
140
173
  create_sample_failure
@@ -177,7 +210,7 @@ module Sidekiq
177
210
  end
178
211
  end
179
212
 
180
- def create_sample_failure
213
+ def create_sample_failure(data = {})
181
214
  data = {
182
215
  :queue => 'default',
183
216
  :class => 'HardWorker',
@@ -188,7 +221,7 @@ module Sidekiq
188
221
  :error_class => 'ArgumentError',
189
222
  :error_message => 'Some new message',
190
223
  :error_backtrace => ["path/file1.rb", "path/file2.rb"]
191
- }
224
+ }.merge(data)
192
225
 
193
226
  Sidekiq.redis do |c|
194
227
  c.multi do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-failures
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Silveira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-22 00:00:00.000000000 Z
11
+ date: 2014-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq