Commit 7529b5631b3052f9c8cd367518897e869e1945ae

Authored by Shuky Dvir
1 parent e4a1b610
Exists in master and in 1 other branch production

added the pushover to notification services

Gemfile
... ... @@ -44,7 +44,10 @@ gem 'octokit', '~> 1.0.0'
44 44 gem 'campy'
45 45 # Hipchat
46 46 gem 'hipchat'
  47 +# Hoiio
47 48 gem 'hoi'
  49 +# Pushover
  50 +gem 'rushover'
48 51  
49 52 # Authentication
50 53 # ---------------------------------------
... ...
Gemfile.lock
... ... @@ -262,6 +262,9 @@ GEM
262 262 ruby-fogbugz (0.1.1)
263 263 crack
264 264 rubyzip (0.9.9)
  265 + rushover (0.1.1)
  266 + json
  267 + rest-client
265 268 selenium-webdriver (2.25.0)
266 269 childprocess (>= 0.2.5)
267 270 libwebsocket (~> 0.1.3)
... ... @@ -349,6 +352,7 @@ DEPENDENCIES
349 352 rspec-rails (~> 2.6)
350 353 ruby-debug
351 354 ruby-fogbugz
  355 + rushover
352 356 therubyracer
353 357 thin
354 358 timecop
... ...
app/assets/images/pushover_create.png 0 → 100644

1.91 KB

app/assets/images/pushover_goto.png 0 → 100644

1.91 KB

app/assets/images/pushover_inactive.png 0 → 100644

1.02 KB

app/models/notification_services/pushover_service.rb 0 → 100644
... ... @@ -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 29 \ No newline at end of file
... ...
spec/fabricators/notification_service_fabricator.rb
... ... @@ -5,6 +5,6 @@ Fabricator :notification_service do
5 5 subdomain { sequence :word }
6 6 end
7 7  
8   -%w(campfire hipchat hoiio).each do |t|
  8 +%w(campfire hipchat hoiio pushover).each do |t|
9 9 Fabricator "#{t}_notification_service".to_sym, :from => :notification_service, :class_name => "NotificationService::#{t.camelcase}Service"
10 10 end
... ...
spec/models/notification_service/pushover_service_spec.rb 0 → 100644
... ... @@ -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 21 \ No newline at end of file
... ...