sidekiq-failures 0.4.2 → 0.4.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: ef8e45759e8632e06c43e6d68074a4c12c8e4ad6
4
- data.tar.gz: 9388a41322307036eeee488e71be8695c481fa9b
3
+ metadata.gz: dbf773e3881e5c3f66679dc77ce221997c58442d
4
+ data.tar.gz: 8fde6abd64a06cd529e7bf523a8f018c68cd9900
5
5
  SHA512:
6
- metadata.gz: 1975b9a74bbaea66c03dad69e62b5ed007a4137cd0c9d634238d0a4f15bb28f6a6eb0aa3395433392f0d19f6408f655ebf944052623fd4fad55b40460c6f5750
7
- data.tar.gz: dc950ec4c3015ddfab679297011e284127ffb16adb62ad931b8e7cb049aafa303b2f29dfbd05bbe9b19c1764be569870b92173b98150488c443d199597291fa0
6
+ metadata.gz: 61dc54a740b82bd9317bec3240468dcd9fdb30663cc2eea05c2368fb117c307e5eeb2979388309177fd7c5a1bec692997e041675d6bba5d11265e95d8492a069
7
+ data.tar.gz: 58fca490bba04d832220c1ee1689cb19adfb6a0b457d76fbd79f82b1171ace187990cd47147f3ac8c081bcf36453bb1aa0d858b923bdb2f91058048b27984050
data/.gitignore CHANGED
@@ -15,3 +15,6 @@ test/tmp
15
15
  test/version_tmp
16
16
  tmp
17
17
  Gemfile.lock
18
+ .ruby-version
19
+ .ruby-gemset
20
+
data/.travis.yml CHANGED
@@ -8,9 +8,10 @@ rvm:
8
8
  - 2.1
9
9
  env:
10
10
  matrix:
11
- - SIDEKIQ_VERSION="~> 2.16.0"
12
- - SIDEKIQ_VERSION="~> 2.17.0"
13
- - SIDEKIQ_VERSION="~> 3.0.0"
11
+ - SIDEKIQ_VERSION="~> 2.16"
12
+ - SIDEKIQ_VERSION="~> 2.17"
13
+ - SIDEKIQ_VERSION="~> 3.0"
14
+ - SIDEKIQ_VERSION="~> 3.1"
14
15
  matrix:
15
16
  allow_failures:
16
17
  - rvm: 1.9.3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 0.4.3
4
+ * Handle numeric timestamps format (@krasnoukhov)
5
+
3
6
  ## 0.4.2
4
7
  * Bump sidekiq dependency to 2.16.0 (@davetoxa)
5
8
  * Handle legacy timestamps (@maltoe)
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Failures
3
- VERSION = "0.4.2"
3
+ VERSION = "0.4.3"
4
4
  end
5
5
  end
@@ -41,7 +41,7 @@
41
41
  <td>
42
42
  <a href="<%= root_path %>queues/<%= entry.queue %>"><%= entry.queue %></a>
43
43
  </td>
44
- <td><%= relative_time(entry['failed_at'].is_a?(Float) ? Time.at(entry['failed_at']) : Time.parse(entry['failed_at'])) %></td>
44
+ <td><%= safe_relative_time(entry['failed_at']) %></td>
45
45
  <td style="overflow: auto; padding: 10px;">
46
46
  <a class="backtrace" href="#" onclick="$(this).next().toggle(); return false">
47
47
  <%= h entry['error_class'] %>: <%= h entry['error_message'] %>
@@ -5,6 +5,18 @@ module Sidekiq
5
5
  def self.registered(app)
6
6
  view_path = File.join(File.expand_path("..", __FILE__), "views")
7
7
 
8
+ app.helpers do
9
+ def safe_relative_time(time)
10
+ time = if time.is_a?(Numeric)
11
+ Time.at(time)
12
+ else
13
+ Time.parse(time)
14
+ end
15
+
16
+ relative_time(time)
17
+ end
18
+ end
19
+
8
20
  app.get "/failures" do
9
21
  @count = (params[:count] || 25).to_i
10
22
  (@current_page, @total_size, @failures) = page(LIST_KEY, params[:page], @count)
@@ -135,50 +135,6 @@ 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
-
171
- describe 'when there are failures with old timestamp format' do
172
- before do
173
- create_sample_failure failed_at: Time.now.strftime('%Y-%m-%dT%H:%M:%SZ')
174
- get '/failures'
175
- end
176
-
177
- it 'should be successful' do
178
- last_response.status.must_equal 200
179
- end
180
- end
181
-
182
138
  describe 'when there is failure' do
183
139
  before do
184
140
  create_sample_failure
@@ -221,6 +177,47 @@ module Sidekiq
221
177
  end
222
178
  end
223
179
 
180
+ describe 'when there is specific failure' do
181
+ describe 'with unescaped data' do
182
+ before do
183
+ create_sample_failure(args: ['<h1>omg</h1>'], error_message: '<p>wow</p>')
184
+ get '/failures'
185
+ end
186
+
187
+ it 'can escape arguments' do
188
+ last_response.body.must_match /&quot;&lt;h1&gt;omg&lt;&#x2F;h1&gt;&quot;/
189
+ end
190
+
191
+ it 'can escape error message' do
192
+ last_response.body.must_match /ArgumentError: &lt;p&gt;wow&lt;&#x2F;p&gt;/
193
+ end
194
+ end
195
+
196
+ describe 'with deprecated payload' do
197
+ before do
198
+ create_sample_failure(args: nil, payload: { args: ['bob', 5] })
199
+ get '/failures'
200
+ end
201
+
202
+ it 'should be successful' do
203
+ last_response.status.must_equal 200
204
+ last_response.body.wont_match /No failed jobs found/
205
+ end
206
+ end
207
+
208
+ describe 'with deprecated timestamp' do
209
+ before do
210
+ create_sample_failure(failed_at: Time.now.strftime('%Y-%m-%dT%H:%M:%SZ'))
211
+ get '/failures'
212
+ end
213
+
214
+ it 'should be successful' do
215
+ last_response.status.must_equal 200
216
+ last_response.body.wont_match /No failed jobs found/
217
+ end
218
+ end
219
+ end
220
+
224
221
  def create_sample_failure(data = {})
225
222
  data = {
226
223
  :queue => 'default',
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.2
4
+ version: 0.4.3
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-06-07 00:00:00.000000000 Z
11
+ date: 2014-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq