Commit 7529b5631b3052f9c8cd367518897e869e1945ae
1 parent
e4a1b610
Exists in
master
and in
1 other branch
added the pushover to notification services
Showing
8 changed files
with
56 additions
and
1 deletions
Show diff stats
Gemfile
| @@ -44,7 +44,10 @@ gem 'octokit', '~> 1.0.0' | @@ -44,7 +44,10 @@ gem 'octokit', '~> 1.0.0' | ||
| 44 | gem 'campy' | 44 | gem 'campy' |
| 45 | # Hipchat | 45 | # Hipchat |
| 46 | gem 'hipchat' | 46 | gem 'hipchat' |
| 47 | +# Hoiio | ||
| 47 | gem 'hoi' | 48 | gem 'hoi' |
| 49 | +# Pushover | ||
| 50 | +gem 'rushover' | ||
| 48 | 51 | ||
| 49 | # Authentication | 52 | # Authentication |
| 50 | # --------------------------------------- | 53 | # --------------------------------------- |
Gemfile.lock
| @@ -262,6 +262,9 @@ GEM | @@ -262,6 +262,9 @@ GEM | ||
| 262 | ruby-fogbugz (0.1.1) | 262 | ruby-fogbugz (0.1.1) |
| 263 | crack | 263 | crack |
| 264 | rubyzip (0.9.9) | 264 | rubyzip (0.9.9) |
| 265 | + rushover (0.1.1) | ||
| 266 | + json | ||
| 267 | + rest-client | ||
| 265 | selenium-webdriver (2.25.0) | 268 | selenium-webdriver (2.25.0) |
| 266 | childprocess (>= 0.2.5) | 269 | childprocess (>= 0.2.5) |
| 267 | libwebsocket (~> 0.1.3) | 270 | libwebsocket (~> 0.1.3) |
| @@ -349,6 +352,7 @@ DEPENDENCIES | @@ -349,6 +352,7 @@ DEPENDENCIES | ||
| 349 | rspec-rails (~> 2.6) | 352 | rspec-rails (~> 2.6) |
| 350 | ruby-debug | 353 | ruby-debug |
| 351 | ruby-fogbugz | 354 | ruby-fogbugz |
| 355 | + rushover | ||
| 352 | therubyracer | 356 | therubyracer |
| 353 | thin | 357 | thin |
| 354 | timecop | 358 | timecop |
1.91 KB
1.91 KB
1.02 KB
| @@ -0,0 +1,28 @@ | @@ -0,0 +1,28 @@ | ||
| 1 | +class NotificationServices::PushoverService < NotificationService | ||
| 2 | + Label = "pushover" | ||
| 3 | + Fields = [ | ||
| 4 | + [:api_token, { | ||
| 5 | + :placeholder => "User Key", | ||
| 6 | + :label => "User Key" | ||
| 7 | + }], | ||
| 8 | + [:subdomain, { | ||
| 9 | + :placeholder => "Application API Token", | ||
| 10 | + :label => "Application API Token" | ||
| 11 | + }] | ||
| 12 | + ] | ||
| 13 | + | ||
| 14 | + def check_params | ||
| 15 | + if Fields.detect {|f| self[f[0]].blank? } | ||
| 16 | + errors.add :base, 'You must specify your User Key and Application API Token.' | ||
| 17 | + end | ||
| 18 | + end | ||
| 19 | + | ||
| 20 | + def create_notification(problem) | ||
| 21 | + # build the hoi client | ||
| 22 | + notification = Rushover::Client.new(subdomain) | ||
| 23 | + | ||
| 24 | + # send push notification to pushover | ||
| 25 | + notification.notify(api_token, "#{notification_description problem}", :priority => 1, :title => "Errbit Notification", :url => "http://#{Errbit::Config.host}/apps/#{problem.app.id.to_s}", :url_title => "Link to error") | ||
| 26 | + | ||
| 27 | + end | ||
| 28 | +end | ||
| 0 | \ No newline at end of file | 29 | \ No newline at end of file |
spec/fabricators/notification_service_fabricator.rb
| @@ -5,6 +5,6 @@ Fabricator :notification_service do | @@ -5,6 +5,6 @@ Fabricator :notification_service do | ||
| 5 | subdomain { sequence :word } | 5 | subdomain { sequence :word } |
| 6 | end | 6 | end |
| 7 | 7 | ||
| 8 | -%w(campfire hipchat hoiio).each do |t| | 8 | +%w(campfire hipchat hoiio pushover).each do |t| |
| 9 | Fabricator "#{t}_notification_service".to_sym, :from => :notification_service, :class_name => "NotificationService::#{t.camelcase}Service" | 9 | Fabricator "#{t}_notification_service".to_sym, :from => :notification_service, :class_name => "NotificationService::#{t.camelcase}Service" |
| 10 | end | 10 | end |
spec/models/notification_service/pushover_service_spec.rb
0 → 100644
| @@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
| 1 | +require 'spec_helper' | ||
| 2 | + | ||
| 3 | +describe NotificationService::PushoverService do | ||
| 4 | + it "it should send a notification to Pushover" do | ||
| 5 | + # setup | ||
| 6 | + notice = Fabricate :notice | ||
| 7 | + notification_service = Fabricate :pushover_notification_service, :app => notice.app | ||
| 8 | + problem = notice.problem | ||
| 9 | + | ||
| 10 | + # hoi stubbing | ||
| 11 | + notification = mock('PushoverService') | ||
| 12 | + Rushover::Client.stub(:new).and_return(notification) | ||
| 13 | + notification.stub(:notify) { true } | ||
| 14 | + | ||
| 15 | + #assert | ||
| 16 | + notification.should_receive(:notify) | ||
| 17 | + | ||
| 18 | + notification_service.create_notification(problem) | ||
| 19 | + end | ||
| 20 | +end | ||
| 0 | \ No newline at end of file | 21 | \ No newline at end of file |