sidekiq-failures 1.0.1 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 411bc0eb000e29f27b3d5afd27e39719c693df17ce7b08baace66e42f4b8c402
4
- data.tar.gz: 88174d41395b3953bf089590775e8e34725c4f47109a379727df08c4331ad8d8
3
+ metadata.gz: 71e370c4485d8ecc481914afd5d8a489c9f2743c1749975dceb536977607230a
4
+ data.tar.gz: 1a8e989912c378459e478eb9f29c0dd1d53128c126cc135c2bf597375e26ed84
5
5
  SHA512:
6
- metadata.gz: 90a60cb2e7b0e8dac73aa3cc188d81e4616354ecdc259bb82680fea63cf2e171e19ddb009f21b686ab95fe30fcb9b0090d45335aaaf16c4985d9770e584aa749
7
- data.tar.gz: 76886912d60887ed578b1b9d2e3ac0b4824b0db0087d776f590ef6c2cf060ad543d331848173c4e0c285ce72789c315586a4bbea6ce7f8b777db9ea17a293057
6
+ metadata.gz: 49f99dbee68555a41e53d615e27afa48f5852d0f887fd96891864c89fd86f5d72fe552d9eefa5b22f860502d6bed321c38f5a4fd28ea5c4f1dfeea703c9d17eb
7
+ data.tar.gz: f59b94960937b9f7d3482c79f79b905015fac87df83bcde5db946023383658138d7226003431a4ece758780f0ad06e7a1b2785258917d19fc5a9278fe6583267
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
@@ -0,0 +1,37 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby: [2.6, 2.7, '3.0', 3.1]
16
+ sidekiq: [4.2, 5.2, 6.2]
17
+ services:
18
+ redis:
19
+ image: redis
20
+ options: >-
21
+ --health-cmd "redis-cli ping"
22
+ --health-interval 10s
23
+ --health-timeout 5s
24
+ --health-retries 5
25
+ ports:
26
+ - 6379:6379
27
+ env:
28
+ SIDEKIQ_VERSION: ~> ${{ matrix.sidekiq }}
29
+ steps:
30
+ - uses: actions/checkout@v3
31
+ - name: Set up Ruby
32
+ uses: ruby/setup-ruby@v1
33
+ with:
34
+ bundler-cache: true # 'bundle install' and cache gems
35
+ ruby-version: ${{ matrix.ruby }}
36
+ - name: Run tests
37
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -17,4 +17,4 @@ tmp
17
17
  Gemfile.lock
18
18
  .ruby-version
19
19
  .ruby-gemset
20
-
20
+ .tool-versions
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 1.0.4
4
+
5
+ * Sanitize failure text on the failure details page (#144 @mcasper)
6
+
7
+ ## 1.0.3
8
+
9
+ * Expand failure descriptions with pure JS (#141 @icyleaf)
10
+
11
+ ## 1.0.2
12
+
13
+ * Pass now required argument to Sidekiq's JobRetry.new (#140 @mcasper)
14
+
3
15
  ## 1.0.1
4
16
 
5
17
  * Add license config to the gemspec (#115 @reiz)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Sidekiq::Failures [![Build Status](https://secure.travis-ci.org/mhfs/sidekiq-failures.png)](http://travis-ci.org/mhfs/sidekiq-failures)
1
+ # Sidekiq::Failures ![Build Status](https://github.com/mhfs/sidekiq-failures/workflows/CI/badge.svg)
2
2
 
3
3
  Keeps track of Sidekiq failed jobs and adds a tab to the Web UI to let you browse
4
4
  them. Makes use of Sidekiq's custom tabs and middleware chain.
@@ -20,6 +20,8 @@ gem 'sidekiq-failures'
20
20
  Simply having the gem in your Gemfile is enough to get you started. Your failed
21
21
  jobs will be visible via a Failures tab in the Web UI.
22
22
 
23
+ If you have not previously used the Web UI, it is a part of the Sidekiq gem. [See Sidekiq's docs about Web UI here.](https://github.com/mperham/sidekiq/wiki/Monitoring#web-ui)
24
+
23
25
  ## Configuring
24
26
 
25
27
  ### Maximum Tracked Failures
@@ -0,0 +1,5 @@
1
+ zh-cn:
2
+ FailedJobs: 失败的任务
3
+ FailedAt: 失败时间
4
+ ResetCounter: 重置计数器
5
+ NoFailedJobsFound: 没有发现失败的任务
@@ -81,7 +81,7 @@ module Sidekiq
81
81
 
82
82
  def retry_middleware
83
83
  @retry_middleware ||=
84
- Sidekiq::Failures.retry_middleware_class.new
84
+ Sidekiq::Failures.retry_middleware_class.new(@config || {})
85
85
  end
86
86
 
87
87
  def default_max_retries
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Failures
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.4"
4
4
  end
5
5
  end
@@ -6,12 +6,12 @@
6
6
  <tr>
7
7
  <th><%= t('ErrorClass') %></th>
8
8
  <td>
9
- <code><%= @failure['error_class'] %></code>
9
+ <code><%= h @failure['error_class'] %></code>
10
10
  </td>
11
11
  </tr>
12
12
  <tr>
13
13
  <th><%= t('ErrorMessage') %></th>
14
- <td><%= @failure['error_message'] %></td>
14
+ <td><%= h @failure['error_message'] %></td>
15
15
  </tr>
16
16
  <% if !@failure['error_backtrace'].nil? %>
17
17
  <tr>
@@ -35,7 +35,9 @@
35
35
  <input type='checkbox' name='key[]' value='<%= job_params(entry.item, entry.score) %>' />
36
36
  </label>
37
37
  </td>
38
- <td><a href="<%= root_path %>failures/<%= job_params(entry.item, entry.score) %>"><%= safe_relative_time(entry['failed_at']) %></a></td>
38
+ <td>
39
+ <a href="<%= root_path %>failures/<%= job_params(entry.item, entry.score) %>"><%= safe_relative_time(entry['failed_at']) %></a>
40
+ </td>
39
41
  <td>
40
42
  <a href="<%= root_path %>queues/<%= entry.queue %>"><%= entry.queue %></a>
41
43
  </td>
@@ -44,7 +46,7 @@
44
46
  <div class="args"><%= display_args(entry.respond_to?(:display_args) ? entry.display_args : entry.args) %></div>
45
47
  </td>
46
48
  <td style="overflow: auto; padding: 10px;">
47
- <a class="backtrace" href="#" onclick="$(this).next().toggle(); return false">
49
+ <a class="backtrace" href="javascript:void(0)", onclick="toggle_error_backtrace(this)">
48
50
  <%= h entry['error_class'] %>: <%= h entry['error_message'].to_s.size > 500 ? entry['error_message'][0..500] + '...' : entry['error_message'] %>
49
51
  </a>
50
52
  <pre style="display: none; background: none; border: 0; width: 100%; max-height: 30em; font-size: 0.8em; white-space: nowrap; overflow: auto;">
@@ -76,10 +78,28 @@
76
78
  </div>
77
79
  <% end %>
78
80
 
81
+ <script>
82
+ function toggle_error_backtrace(e) {
83
+ let x = e.nextElementSibling;
84
+ if (x.style.display === "none") {
85
+ x.style.display = "block";
86
+ } else {
87
+ x.style.display = "none";
88
+ }
89
+ }
90
+ </script>
91
+
92
+ <style type="text/css">
93
+ @media only screen and (prefers-color-scheme: dark) {
94
+ pre {
95
+ color: white
96
+ }
97
+ }
98
+ </style>
79
99
  <% else %>
80
100
  <div class="alert alert-success"><%= t('NoFailedJobsFound') %></div>
81
101
  <% end %>
82
102
  <form action="<%= root_path %>failures/all/reset" method="post">
83
103
  <%= csrf_tag if respond_to?(:csrf_tag) %>
84
- <input class="btn btn-danger btn-xs pull-right" type="submit" name="reset" value="<%= t('Reset Counter') %>" data-confirm="<%= t('AreYouSure') %>" />
104
+ <input class="btn btn-danger btn-xs pull-right" type="submit" name="reset" value="<%= t('ResetCounter') %>" data-confirm="<%= t('AreYouSure') %>" />
85
105
  </form>
@@ -10,8 +10,6 @@ Gem::Specification.new do |gem|
10
10
  gem.license = "MIT"
11
11
 
12
12
  gem.files = `git ls-files`.split($\)
13
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
13
  gem.name = "sidekiq-failures"
16
14
  gem.require_paths = ["lib"]
17
15
  gem.version = Sidekiq::Failures::VERSION
@@ -30,4 +28,5 @@ Gem::Specification.new do |gem|
30
28
  gem.add_development_dependency "rack-test"
31
29
  gem.add_development_dependency "sprockets"
32
30
  gem.add_development_dependency "sinatra"
31
+ gem.add_development_dependency "pry"
33
32
  end
@@ -1,19 +1,72 @@
1
1
  require "test_helper"
2
2
 
3
+ class SidekiqPre6
4
+ def new_processor(boss)
5
+ num_options_calls.times { boss.expect(:options, {:queues => ['default'] }, []) }
6
+ ::Sidekiq::Processor.new(boss)
7
+ end
8
+
9
+ private
10
+
11
+ def num_options_calls
12
+ if Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('5.0.3')
13
+ 3
14
+ else
15
+ 2
16
+ end
17
+ end
18
+ end
19
+
20
+ class SidekiqPre63
21
+ def new_processor(boss)
22
+ opts = {
23
+ queues: ['default'],
24
+ }
25
+ opts[:fetch] = Sidekiq::BasicFetch.new(opts)
26
+ ::Sidekiq::Processor.new(boss, opts)
27
+ end
28
+ end
29
+
30
+ class SidekiqPost63
31
+ def new_processor(boss)
32
+ config = Sidekiq
33
+ config[:queues] = ['default']
34
+ config[:fetch] = Sidekiq::BasicFetch.new(config)
35
+ config[:error_handlers] << Sidekiq.method(:default_error_handler)
36
+ ::Sidekiq::Processor.new(config) { |processor, reason = nil| }
37
+ end
38
+ end
39
+
3
40
  module Sidekiq
4
41
  module Failures
5
42
  describe "Middleware" do
43
+ def new_provider
44
+ version = Gem::Version.new(Sidekiq::VERSION)
45
+ if version >= Gem::Version.new('6.4.0')
46
+ SidekiqPost63
47
+ elsif version >= Gem::Version.new('6.0')
48
+ SidekiqPre63
49
+ else
50
+ SidekiqPre6
51
+ end.new
52
+ end
53
+
6
54
  before do
7
55
  $invokes = 0
8
56
  @boss = MiniTest::Mock.new
9
- num_options_calls.times { @boss.expect(:options, {:queues => ['default'] }, []) }
10
- @processor = ::Sidekiq::Processor.new(@boss)
57
+ @provider = new_provider
58
+ @processor = @provider.new_processor(@boss)
59
+
11
60
  Sidekiq.server_middleware {|chain| chain.add Sidekiq::Failures::Middleware }
12
61
  Sidekiq.redis = REDIS
13
62
  Sidekiq.redis { |c| c.flushdb }
14
63
  Sidekiq.instance_eval { @failures_default_mode = nil }
15
64
  end
16
65
 
66
+ after do
67
+ @boss.verify
68
+ end
69
+
17
70
  TestException = Class.new(Exception)
18
71
  ShutdownException = Class.new(Sidekiq::Shutdown)
19
72
 
@@ -42,11 +95,6 @@ module Sidekiq
42
95
 
43
96
  assert_equal 0, failures_count
44
97
 
45
- actor = MiniTest::Mock.new
46
- actor.expect(:processor_done, nil, [@processor])
47
- actor.expect(:real_thread, nil, [nil, nil])
48
- 2.times { @boss.expect(:async, actor, []) }
49
-
50
98
  assert_raises TestException do
51
99
  @processor.process(msg)
52
100
  end
@@ -60,11 +108,6 @@ module Sidekiq
60
108
 
61
109
  assert_equal 0, failures_count
62
110
 
63
- actor = MiniTest::Mock.new
64
- actor.expect(:processor_done, nil, [@processor])
65
- actor.expect(:real_thread, nil, [nil, nil])
66
- 2.times { @boss.expect(:async, actor, []) }
67
-
68
111
  assert_raises TestException do
69
112
  @processor.process(msg)
70
113
  end
@@ -78,12 +121,7 @@ module Sidekiq
78
121
 
79
122
  assert_equal 0, failures_count
80
123
 
81
- actor = MiniTest::Mock.new
82
- actor.expect(:processor_done, nil, [@processor])
83
- actor.expect(:real_thread, nil, [nil, nil])
84
-
85
124
  @processor.process(msg)
86
- @boss.verify
87
125
 
88
126
  assert_equal 0, failures_count
89
127
  assert_equal 1, $invokes
@@ -94,11 +132,6 @@ module Sidekiq
94
132
 
95
133
  assert_equal 0, failures_count
96
134
 
97
- actor = MiniTest::Mock.new
98
- actor.expect(:processor_done, nil, [@processor])
99
- actor.expect(:real_thread, nil, [nil, nil])
100
- 2.times { @boss.expect(:async, actor, []) }
101
-
102
135
  assert_raises TestException do
103
136
  @processor.process(msg)
104
137
  end
@@ -114,11 +147,6 @@ module Sidekiq
114
147
 
115
148
  assert_equal 0, failures_count
116
149
 
117
- actor = MiniTest::Mock.new
118
- actor.expect(:processor_done, nil, [@processor])
119
- actor.expect(:real_thread, nil, [nil, nil])
120
- 2.times { @boss.expect(:async, actor, []) }
121
-
122
150
  assert_raises TestException do
123
151
  @processor.process(msg)
124
152
  end
@@ -133,11 +161,6 @@ module Sidekiq
133
161
 
134
162
  assert_equal 0, failures_count
135
163
 
136
- actor = MiniTest::Mock.new
137
- actor.expect(:processor_done, nil, [@processor])
138
- actor.expect(:real_thread, nil, [nil, nil])
139
- 2.times { @boss.expect(:async, actor, []) }
140
-
141
164
  assert_raises TestException do
142
165
  @processor.process(msg)
143
166
  end
@@ -151,11 +174,6 @@ module Sidekiq
151
174
 
152
175
  assert_equal 0, failures_count
153
176
 
154
- actor = MiniTest::Mock.new
155
- actor.expect(:processor_done, nil, [@processor])
156
- actor.expect(:real_thread, nil, [nil, nil])
157
- 2.times { @boss.expect(:async, actor, []) }
158
-
159
177
  assert_raises TestException do
160
178
  @processor.process(msg)
161
179
  end
@@ -169,11 +187,6 @@ module Sidekiq
169
187
 
170
188
  assert_equal 0, failures_count
171
189
 
172
- actor = MiniTest::Mock.new
173
- actor.expect(:processor_done, nil, [@processor])
174
- actor.expect(:real_thread, nil, [nil, nil])
175
- 2.times { @boss.expect(:async, actor, []) }
176
-
177
190
  assert_raises TestException do
178
191
  @processor.process(msg)
179
192
  end
@@ -189,11 +202,6 @@ module Sidekiq
189
202
 
190
203
  assert_equal 0, failures_count
191
204
 
192
- actor = MiniTest::Mock.new
193
- actor.expect(:processor_done, nil, [@processor])
194
- actor.expect(:real_thread, nil, [nil, nil])
195
- 2.times { @boss.expect(:async, actor, []) }
196
-
197
205
  assert_raises TestException do
198
206
  @processor.process(msg)
199
207
  end
@@ -209,11 +217,6 @@ module Sidekiq
209
217
 
210
218
  assert_equal 0, failures_count
211
219
 
212
- actor = MiniTest::Mock.new
213
- actor.expect(:processor_done, nil, [@processor])
214
- actor.expect(:real_thread, nil, [nil, nil])
215
- 2.times { @boss.expect(:async, actor, []) }
216
-
217
220
  assert_raises TestException do
218
221
  @processor.process(msg)
219
222
  end
@@ -232,17 +235,13 @@ module Sidekiq
232
235
 
233
236
  3.times do
234
237
  boss = MiniTest::Mock.new
235
- num_options_calls.times { boss.expect(:options, {:queues => ['default'] }, []) }
236
- processor = ::Sidekiq::Processor.new(boss)
237
-
238
- actor = MiniTest::Mock.new
239
- actor.expect(:processor_done, nil, [processor])
240
- actor.expect(:real_thread, nil, [nil, nil])
241
- 2.times { boss.expect(:async, actor, []) }
238
+ processor = @provider.new_processor(boss)
242
239
 
243
240
  assert_raises TestException do
244
241
  processor.process(msg)
245
242
  end
243
+
244
+ boss.verify
246
245
  end
247
246
 
248
247
  assert_equal 2, failures_count
@@ -259,11 +258,6 @@ module Sidekiq
259
258
 
260
259
  assert_equal 0, Sidekiq::Failures.count
261
260
 
262
- actor = MiniTest::Mock.new
263
- actor.expect(:processor_done, nil, [@processor])
264
- actor.expect(:real_thread, nil, [nil, nil])
265
- @boss.expect(:async, actor, [])
266
-
267
261
  assert_raises TestException do
268
262
  @processor.process(msg)
269
263
  end
@@ -278,14 +272,6 @@ module Sidekiq
278
272
  def create_work(msg)
279
273
  Sidekiq::BasicFetch::UnitOfWork.new('default', Sidekiq.dump_json(msg))
280
274
  end
281
-
282
- def num_options_calls
283
- if Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('5.0.3')
284
- 3
285
- else
286
- 2
287
- end
288
- end
289
275
  end
290
276
  end
291
277
  end
@@ -21,22 +21,22 @@ module Sidekiq
21
21
  it 'can display home with failures tab' do
22
22
  get '/'
23
23
 
24
- last_response.status.must_equal 200
25
- last_response.body.must_match(/Sidekiq/)
26
- last_response.body.must_match(/Failures/)
24
+ _(last_response.status).must_equal 200
25
+ _(last_response.body).must_match(/Sidekiq/)
26
+ _(last_response.body).must_match(/Failures/)
27
27
  end
28
28
 
29
29
  it 'can display failures page without any failures' do
30
30
  get '/failures'
31
- last_response.status.must_equal 200
32
- last_response.body.must_match(/Failed Jobs/)
33
- last_response.body.must_match(/No failed jobs found/)
31
+ _(last_response.status).must_equal 200
32
+ _(last_response.body).must_match(/Failed Jobs/)
33
+ _(last_response.body).must_match(/No failed jobs found/)
34
34
  end
35
35
 
36
36
  it 'has the reset counter form and action' do
37
37
  get '/failures'
38
- last_response.body.must_match(/failures\/all\/reset/)
39
- last_response.body.must_match(/Reset Counter/)
38
+ _(last_response.body).must_match(/failures\/all\/reset/)
39
+ _(last_response.body).must_match(/Reset Counter/)
40
40
  end
41
41
 
42
42
  describe 'when there are failures' do
@@ -46,97 +46,97 @@ module Sidekiq
46
46
  end
47
47
 
48
48
  it 'should be successful' do
49
- last_response.status.must_equal 200
49
+ _(last_response.status).must_equal 200
50
50
  end
51
51
 
52
52
  it 'can display failures page with failures listed' do
53
- last_response.body.must_match(/Failed Jobs/)
54
- last_response.body.must_match(/HardWorker/)
55
- last_response.body.must_match(/ArgumentError/)
56
- last_response.body.wont_match(/No failed jobs found/)
53
+ _(last_response.body).must_match(/Failed Jobs/)
54
+ _(last_response.body).must_match(/HardWorker/)
55
+ _(last_response.body).must_match(/ArgumentError/)
56
+ _(last_response.body).wont_match(/No failed jobs found/)
57
57
  end
58
58
 
59
59
  it 'can reset counter' do
60
60
  assert_equal failed_count, "1"
61
61
 
62
- last_response.body.must_match(/HardWorker/)
62
+ _(last_response.body).must_match(/HardWorker/)
63
63
 
64
64
  post '/failures/all/reset'
65
- last_response.status.must_equal 302
66
- last_response.location.must_match(/failures$/)
65
+ _(last_response.status).must_equal 302
66
+ _(last_response.location).must_match(/failures$/)
67
67
 
68
68
  get '/failures'
69
- last_response.status.must_equal 200
70
- last_response.body.must_match(/HardWorker/)
69
+ _(last_response.status).must_equal 200
70
+ _(last_response.body).must_match(/HardWorker/)
71
71
 
72
72
  assert_equal failed_count, "0"
73
73
  end
74
74
 
75
75
  it 'has the delete all form and action' do
76
- last_response.body.must_match(/failures\/all\/delete/)
77
- last_response.body.must_match(/Delete All/)
76
+ _(last_response.body).must_match(/failures\/all\/delete/)
77
+ _(last_response.body).must_match(/Delete All/)
78
78
  end
79
79
 
80
80
  it 'can delete all failures' do
81
81
  assert_equal failed_count, "1"
82
82
 
83
- last_response.body.must_match(/HardWorker/)
83
+ _(last_response.body).must_match(/HardWorker/)
84
84
 
85
85
  post '/failures/all/delete'
86
- last_response.status.must_equal 302
87
- last_response.location.must_match(/failures$/)
86
+ _(last_response.status).must_equal 302
87
+ _(last_response.location).must_match(/failures$/)
88
88
 
89
89
  get '/failures'
90
- last_response.status.must_equal 200
91
- last_response.body.must_match(/No failed jobs found/)
90
+ _(last_response.status).must_equal 200
91
+ _(last_response.body).must_match(/No failed jobs found/)
92
92
 
93
93
  assert_equal failed_count, "1"
94
94
  end
95
95
 
96
96
  it 'has the retry all form and action' do
97
- last_response.body.must_match(/failures\/all\/retry/)
98
- last_response.body.must_match(/Retry All/)
97
+ _(last_response.body).must_match(/failures\/all\/retry/)
98
+ _(last_response.body).must_match(/Retry All/)
99
99
  end
100
100
 
101
101
  it 'can retry all failures' do
102
102
  assert_equal failed_count, "1"
103
103
 
104
- last_response.body.must_match(/HardWorker/)
104
+ _(last_response.body).must_match(/HardWorker/)
105
105
  post '/failures/all/retry'
106
- last_response.status.must_equal 302
107
- last_response.location.must_match(/failures/)
106
+ _(last_response.status).must_equal 302
107
+ _(last_response.location).must_match(/failures/)
108
108
 
109
109
  get '/failures'
110
- last_response.status.must_equal 200
111
- last_response.body.must_match(/No failed jobs found/)
110
+ _(last_response.status).must_equal 200
111
+ _(last_response.body).must_match(/No failed jobs found/)
112
112
  end
113
113
 
114
114
  it 'can delete failure from the list' do
115
115
  assert_equal failed_count, "1"
116
116
 
117
- last_response.body.must_match(/HardWorker/)
117
+ _(last_response.body).must_match(/HardWorker/)
118
118
 
119
119
  post '/failures', { :key => [failure_score], :delete => 'Delete' }
120
- last_response.status.must_equal 302
121
- last_response.location.must_match(/failures/)
120
+ _(last_response.status).must_equal 302
121
+ _(last_response.location).must_match(/failures/)
122
122
 
123
123
  get '/failures'
124
- last_response.status.must_equal 200
125
- last_response.body.must_match(/No failed jobs found/)
124
+ _(last_response.status).must_equal 200
125
+ _(last_response.body).must_match(/No failed jobs found/)
126
126
  end
127
127
 
128
128
  it 'can retry failure from the list' do
129
129
  assert_equal failed_count, "1"
130
130
 
131
- last_response.body.must_match(/HardWorker/)
131
+ _(last_response.body).must_match(/HardWorker/)
132
132
 
133
133
  post '/failures', { :key => [failure_score], :retry => 'Retry Now' }
134
- last_response.status.must_equal 302
135
- last_response.location.must_match(/failures/)
134
+ _(last_response.status).must_equal 302
135
+ _(last_response.location).must_match(/failures/)
136
136
 
137
137
  get '/failures'
138
- last_response.status.must_equal 200
139
- last_response.body.must_match(/No failed jobs found/)
138
+ _(last_response.status).must_equal 200
139
+ _(last_response.body).must_match(/No failed jobs found/)
140
140
  end
141
141
 
142
142
  it 'can handle failures with nil error_message' do
@@ -144,7 +144,7 @@ module Sidekiq
144
144
 
145
145
  get '/failures'
146
146
 
147
- last_response.status.must_equal 200
147
+ _(last_response.status).must_equal 200
148
148
  end
149
149
  end
150
150
 
@@ -155,38 +155,38 @@ module Sidekiq
155
155
  end
156
156
 
157
157
  it 'should be successful' do
158
- last_response.status.must_equal 200
158
+ _(last_response.status).must_equal 200
159
159
  end
160
160
 
161
161
  it 'can display failure page' do
162
- last_response.body.must_match(/Job/)
163
- last_response.body.must_match(/HardWorker/)
164
- last_response.body.must_match(/ArgumentError/)
165
- last_response.body.must_match(/file1/)
162
+ _(last_response.body).must_match(/Job/)
163
+ _(last_response.body).must_match(/HardWorker/)
164
+ _(last_response.body).must_match(/ArgumentError/)
165
+ _(last_response.body).must_match(/file1/)
166
166
  end
167
167
 
168
168
  it 'can delete failure' do
169
- last_response.body.must_match(/HardWorker/)
169
+ _(last_response.body).must_match(/HardWorker/)
170
170
 
171
171
  post "/failures/#{failure_score}", :delete => 'Delete'
172
- last_response.status.must_equal 302
173
- last_response.location.must_match(/failures/)
172
+ _(last_response.status).must_equal 302
173
+ _(last_response.location).must_match(/failures/)
174
174
 
175
175
  get "/failures/#{failure_score}"
176
- last_response.status.must_equal 302
177
- last_response.location.must_match(/failures/)
176
+ _(last_response.status).must_equal 302
177
+ _(last_response.location).must_match(/failures/)
178
178
  end
179
179
 
180
180
  it 'can retry failure' do
181
- last_response.body.must_match(/HardWorker/)
181
+ _(last_response.body).must_match(/HardWorker/)
182
182
 
183
183
  post "/failures/#{failure_score}", :retry => 'Retry Now'
184
- last_response.status.must_equal 302
185
- last_response.location.must_match(/failures/)
184
+ _(last_response.status).must_equal 302
185
+ _(last_response.location).must_match(/failures/)
186
186
 
187
187
  get "/failures/#{failure_score}"
188
- last_response.status.must_equal 302
189
- last_response.location.must_match(/failures/)
188
+ _(last_response.status).must_equal 302
189
+ _(last_response.location).must_match(/failures/)
190
190
  end
191
191
 
192
192
  if defined? Sidekiq::Pro
@@ -194,24 +194,43 @@ module Sidekiq
194
194
  create_sample_failure
195
195
  post '/filter/failures', substr: 'new'
196
196
 
197
- last_response.status.must_equal 200
197
+ _(last_response.status).must_equal 200
198
198
  end
199
199
  end
200
200
  end
201
201
 
202
202
  describe 'when there is specific failure' do
203
203
  describe 'with unescaped data' do
204
- before do
205
- create_sample_failure(args: ['<h1>omg</h1>'], error_message: '<p>wow</p>')
206
- get '/failures'
204
+ describe 'the index page' do
205
+ before do
206
+ create_sample_failure(args: ['<h1>omg</h1>'], error_message: '<p>wow</p>')
207
+ get '/failures'
208
+ end
209
+
210
+ it 'can escape arguments' do
211
+ _(last_response.body).must_match(/&quot;&lt;h1&gt;omg&lt;&#x2F;h1&gt;&quot;/)
212
+ end
213
+
214
+ it 'can escape error message' do
215
+ _(last_response.body).must_match(/ArgumentError: &lt;p&gt;wow&lt;&#x2F;p&gt;/)
216
+ end
207
217
  end
208
218
 
209
- it 'can escape arguments' do
210
- last_response.body.must_match(/&quot;&lt;h1&gt;omg&lt;&#x2F;h1&gt;&quot;/)
211
- end
212
-
213
- it 'can escape error message' do
214
- last_response.body.must_match(/ArgumentError: &lt;p&gt;wow&lt;&#x2F;p&gt;/)
219
+ describe 'the details page' do
220
+ before do
221
+ failure = create_sample_failure(args: ['<h1>omg</h1>'], error_message: '<p>wow</p>')
222
+ get "/failures/#{failure[:jid]}"
223
+ end
224
+
225
+ it 'can escape arguments' do
226
+ _(last_response.status).must_equal 200
227
+ _(last_response.body).must_match(/<th>Error Message<\/th>\n <td>&lt;p&gt;wow&lt;&#x2F;p&gt;<\/td>/)
228
+ end
229
+
230
+ it 'can escape error message' do
231
+ _(last_response.status).must_equal 200
232
+ _(last_response.body).must_match(/<th>Error Message<\/th>\n <td>&lt;p&gt;wow&lt;&#x2F;p&gt;<\/td>/)
233
+ end
215
234
  end
216
235
  end
217
236
 
@@ -222,8 +241,8 @@ module Sidekiq
222
241
  end
223
242
 
224
243
  it 'should be successful' do
225
- last_response.status.must_equal 200
226
- last_response.body.wont_match(/No failed jobs found/)
244
+ _(last_response.status).must_equal 200
245
+ _(last_response.body).wont_match(/No failed jobs found/)
227
246
  end
228
247
  end
229
248
 
@@ -234,8 +253,8 @@ module Sidekiq
234
253
  end
235
254
 
236
255
  it 'should be successful' do
237
- last_response.status.must_equal 200
238
- last_response.body.wont_match(/No failed jobs found/)
256
+ _(last_response.status).must_equal 200
257
+ _(last_response.body).wont_match(/No failed jobs found/)
239
258
  end
240
259
  end
241
260
  end
@@ -259,6 +278,8 @@ module Sidekiq
259
278
  c.set("stat:failed", 1)
260
279
  end
261
280
  end
281
+
282
+ data
262
283
  end
263
284
 
264
285
  def failed_count
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: 1.0.1
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Silveira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-03 00:00:00.000000000 Z
11
+ date: 2022-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: Keep track of Sidekiq failed jobs
98
112
  email:
99
113
  - marcelo@mhfs.com.br
@@ -101,8 +115,9 @@ executables: []
101
115
  extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
118
+ - ".github/dependabot.yml"
119
+ - ".github/workflows/ci.yml"
104
120
  - ".gitignore"
105
- - ".travis.yml"
106
121
  - CHANGELOG.md
107
122
  - Gemfile
108
123
  - LICENSE
@@ -114,6 +129,7 @@ files:
114
129
  - lib/sidekiq/failures/locales/en.yml
115
130
  - lib/sidekiq/failures/locales/ja.yml
116
131
  - lib/sidekiq/failures/locales/pt-BR.yml
132
+ - lib/sidekiq/failures/locales/zh-cn.yml
117
133
  - lib/sidekiq/failures/middleware.rb
118
134
  - lib/sidekiq/failures/sorted_entry.rb
119
135
  - lib/sidekiq/failures/version.rb
@@ -144,13 +160,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
160
  - !ruby/object:Gem::Version
145
161
  version: '0'
146
162
  requirements: []
147
- rubygems_version: 3.2.3
163
+ rubygems_version: 3.0.3.1
148
164
  signing_key:
149
165
  specification_version: 4
150
166
  summary: Keeps track of Sidekiq failed jobs and adds a tab to the Web UI to let you
151
167
  browse them. Makes use of Sidekiq's custom tabs and middleware chain.
152
- test_files:
153
- - test/failures_test.rb
154
- - test/middleware_test.rb
155
- - test/test_helper.rb
156
- - test/web_extension_test.rb
168
+ test_files: []
data/.travis.yml DELETED
@@ -1,18 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
- services:
5
- - redis-server
6
- rvm:
7
- - jruby-9.1.6.0
8
- - 2.2.4
9
- - 2.3.0
10
- - 2.4.0
11
- env:
12
- matrix:
13
- - SIDEKIQ_VERSION="~> 4.0"
14
- - SIDEKIQ_VERSION="~> 4.2"
15
- - SIDEKIQ_VERSION="~> 5.0"
16
- matrix:
17
- allow_failures:
18
- - rvm: jruby-9.1.6.0