Commit 690589f65ef23006393722cb93d368cd7a7dbe9f
Exists in
master
and in
1 other branch
Merge branch 'adding_pushover_support' of git://github.com/shukydvir/errbit into…
… shukydvir-adding_pushover_support Conflicts: Gemfile
Showing
8 changed files
with
56 additions
and
1 deletions
Show diff stats
Gemfile
@@ -47,8 +47,11 @@ gem 'bitbucket_rest_api' | @@ -47,8 +47,11 @@ gem 'bitbucket_rest_api' | ||
47 | gem 'campy' | 47 | gem 'campy' |
48 | # Hipchat | 48 | # Hipchat |
49 | gem 'hipchat' | 49 | gem 'hipchat' |
50 | +<<<<<<< HEAD | ||
50 | # Hoiio (SMS) | 51 | # Hoiio (SMS) |
51 | gem 'hoi' | 52 | gem 'hoi' |
53 | +# Pushover (iOS Push notifications) | ||
54 | +gem 'rushover' | ||
52 | 55 | ||
53 | # Authentication | 56 | # Authentication |
54 | # --------------------------------------- | 57 | # --------------------------------------- |
Gemfile.lock
@@ -269,6 +269,9 @@ GEM | @@ -269,6 +269,9 @@ GEM | ||
269 | ruby-fogbugz (0.1.1) | 269 | ruby-fogbugz (0.1.1) |
270 | crack | 270 | crack |
271 | rubyzip (0.9.9) | 271 | rubyzip (0.9.9) |
272 | + rushover (0.1.1) | ||
273 | + json | ||
274 | + rest-client | ||
272 | selenium-webdriver (2.25.0) | 275 | selenium-webdriver (2.25.0) |
273 | childprocess (>= 0.2.5) | 276 | childprocess (>= 0.2.5) |
274 | libwebsocket (~> 0.1.3) | 277 | libwebsocket (~> 0.1.3) |
@@ -362,6 +365,7 @@ DEPENDENCIES | @@ -362,6 +365,7 @@ DEPENDENCIES | ||
362 | rspec-rails (~> 2.6) | 365 | rspec-rails (~> 2.6) |
363 | ruby-debug | 366 | ruby-debug |
364 | ruby-fogbugz | 367 | ruby-fogbugz |
368 | + rushover | ||
365 | therubyracer | 369 | therubyracer |
366 | thin | 370 | thin |
367 | timecop | 371 | 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 |