Skip to content
Browse files

Clear All failures from the UI.

  • Loading branch information...
1 parent a088b5a commit dc1440c26361763f699ce773770c26be6da50c33 @bnorton bnorton committed Sep 29, 2012
Showing with 43 additions and 8 deletions.
  1. +0 −1 README.md
  2. +3 −0 lib/sidekiq/failures/views/failures.slim
  3. +6 −0 lib/sidekiq/failures/web_extension.rb
  4. +34 −7 test/web_extension_test.rb
View
1 README.md
@@ -34,7 +34,6 @@ Your failed jobs will be visible via a Failures tab in the Web UI.
## TODO and Limitations
* Skip failures of specific workers (or the opposite).
-* Remove all failed jobs via Web UI.
* Trigger retry of specific failed jobs via Web UI.
* Deal with retries. Maybe just track a failure when there's no attempt left.
View
3 lib/sidekiq/failures/views/failures.slim
@@ -20,6 +20,9 @@ h1 Failed Jobs
td= msg['error']
td= msg['failed_at']
+ form.form-horizontal action="#{root_path}failures/remove" method="post"
+ input.btn.btn-danger type="submit" name="delete" value="Clear All"
+
== slim :_paging, :locals => { :url => "#{root_path}queues/#{@name}" }
- else
p No failed jobs found.
View
6 lib/sidekiq/failures/web_extension.rb
@@ -18,6 +18,12 @@ def find_template(view, *a, &b)
slim :failures
end
+
+ app.post "/failures/remove" do
+ Sidekiq.redis {|c| c.del(:failed) }
+
+ redirect "#{root_path}/failures"
+ end
end
end
end
View
41 test/web_extension_test.rb
@@ -28,13 +28,40 @@ def app
last_response.body.must_match /No failed jobs found/
end
- it 'can display failures page with failures listed' do
- create_sample_failure
- get '/failures'
- last_response.status.must_equal 200
- last_response.body.must_match /HardWorker/
- last_response.body.must_match /ArgumentError/
- last_response.body.wont_match /No failed jobs found/
+ describe 'when there are failures' do
+ before do
+ create_sample_failure
+ get '/failures'
+ end
+
+ it 'should be successful' do
+ last_response.status.must_equal 200
+ end
+
+ it 'can display failures page with failures listed' do
+ last_response.body.must_match /Failed Jobs/
+ last_response.body.must_match /HardWorker/
+ last_response.body.must_match /ArgumentError/
+ last_response.body.wont_match /No failed jobs found/
+ end
+
+ it 'has the clear all form and action' do
+ last_response.body.must_match /failures\/remove/
+ last_response.body.must_match /method=\"post/
+ last_response.body.must_match /Clear All/
+ end
+
+ it 'can remove all failures' do
+ last_response.body.must_match /HardWorker/
+
+ post '/failures/remove'
+ last_response.status.must_equal 302
+ last_response.location.must_match /failures$/
+
+ get '/failures'
+ last_response.status.must_equal 200
+ last_response.body.must_match /No failed jobs found/
+ end
end
def create_sample_failure

0 comments on commit dc1440c

Please sign in to comment.
Something went wrong with that request. Please try again.