Permalink
Browse files

check descriptions

  • Loading branch information...
1 parent 24c2523 commit 41140069d0ba4e11a5585a0fa0a274db0bf81db9 @alexch committed Aug 5, 2010
Showing with 60 additions and 4 deletions.
  1. +2 −0 README.md
  2. +4 −0 lib/check.rb
  3. +4 −0 lib/countdown.rb
  4. +4 −0 lib/fetch.rb
  5. +4 −0 lib/new_task.rb
  6. +3 −0 lib/send.rb
  7. +24 −0 spec/check_spec.rb
  8. +15 −4 views/new_check.rb
View
@@ -7,3 +7,5 @@ Sentry is basically a Nagios clone: it runs checks every so often, and notifies
* Sentry runs on Heroku, so anyone can create their own instance for the cost of a worker (currently ~$36/mo, which is kind of steep, but might be worth it). (There's no reason it couldn't run on another server too.)
* It's a good example app for Sinatra, Heroku, Erector, Ruby email sending and checking, and TDD.
+
+Check out the demo at http://sentry.heroku.com
View
@@ -1,6 +1,10 @@
require "params"
class Check
+ def self.description
+ nil
+ end
+
include DataMapper::Resource
include Params
include ExceptionReporting
View
@@ -1,4 +1,8 @@
class Countdown < Check
+ def self.description
+ "Decrement a counter once per second (or so). Used to verify that background jobs are working."
+ end
+
def default_params
super.merge(:sec => 10)
end
View
@@ -2,6 +2,10 @@
require 'uri'
class Fetch < Check
+ def self.description
+ "Fetch an HTTP URL; fail only if there's a network error"
+ end
+
def default_params
super.merge("url" => "http://example.com/")
end
View
@@ -4,6 +4,10 @@
# unit test
class NewTask < Check
+ def self.description
+ "Send email to new@cohuman.com, which should create a new task. Wait for the confirmation email."
+ end
+
def default_params
super.merge("period" => 30, "limit" => 600, "to" => "new@cohuman.com")
end
View
@@ -1,4 +1,7 @@
class Send < Check
+ def self.description
+ "Immediately send an email from Sentry"
+ end
def default_params
super.merge(:to => "nobody@example.com")
View
@@ -156,6 +156,30 @@ class Sample < Check
end
end
+ describe "#description" do
+
+ class Soup < Check
+ def self.description
+ "yummy"
+ end
+ end
+
+ class Sandwich < Check
+ end
+
+ it "defaults to nil" do
+ Check.description.should == nil
+ end
+
+ it "defaults to nil for subclasses" do
+ Sandwich.description.should == nil
+ end
+
+ it "can be overridden by a check class" do
+ Soup.description.should == "yummy"
+ end
+ end
+
describe "subclasses" do
class Overrider < Check
def default_params
View
@@ -10,8 +10,8 @@ class NewCheck < Widget
selectedType = selectElement.val();
log(selectedType);
- newCheckTable.find('tr.params_row').hide();
- newCheckTable.find('tr.params_row.' + selectedType).show();
+ newCheckTable.find('tr.check_specific').hide();
+ newCheckTable.find('tr.check_specific.' + selectedType).show();
}
// do it on load
@@ -53,9 +53,19 @@ def check_type_selector_row
end
end
+ def description_row(check_class)
+ if check_class.description
+ check_type = check_class.to_s # todo: put this into Check
+ tr :class => ["check_specific", check_type] do
+ th "description"
+ td check_class.description
+ end
+ end
+ end
+
def params_row(check_class)
- check_type = check_class.to_s
- tr :class => ["params_row", check_type] do
+ check_type = check_class.to_s # todo: put this into Check
+ tr :class => ["check_specific", check_type] do
th "params"
td do
table :class => "#{check_type}_params" do
@@ -103,6 +113,7 @@ def content
table :class => "new_check_table" do
check_type_selector_row
check_classes.each do |check_class|
+ description_row(check_class)
params_row(check_class)
end
schedule_row

0 comments on commit 4114006

Please sign in to comment.